mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2026-04-24 21:06:02 +03:00
[PR #2136] [MERGED] Fixed a bug in handling file names containing CR(0x0D) #2351
Labels
No labels
bug
bug
dataloss
duplicate
enhancement
feature request
help wanted
invalid
need info
performance
pull-request
question
question
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/s3fs-fuse#2351
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/s3fs-fuse/s3fs-fuse/pull/2136
Author: @ggtakec
Created: 3/21/2023
Status: ✅ Merged
Merged: 3/26/2023
Merged by: @ggtakec
Base:
master← Head:fix_name_with_cr📝 Commits (1)
59c3b26Fixed a bug in handling file names containing CR(0x1D)📊 Changes
9 files changed (+247 additions, -5 deletions)
View changed files
📝
.gitignore(+1 -0)📝
src/s3fs.cpp(+8 -1)📝
src/s3fs_xml.cpp(+10 -3)📝
src/string_util.cpp(+83 -0)📝
src/string_util.h(+6 -0)📝
src/test_string_util.cpp(+50 -0)📝
test/Makefile.am(+3 -1)➕
test/cr_filename.c(+76 -0)📝
test/integration-test-main.sh(+10 -0)📄 Description
Relevant Issue (if applicable)
#2067
Details
libxml2 converts
CRcode('\r'=0x0D) toLF('\n'=0x0A) according to the XML specification.Therefore, if the object name(file name) contains
CR,ListBucketwill try to process the object name converted toLF.And as a result, there was a problem that the user could not get the file list.
The fix is to escape(
%0D) theCRcode fromListBucketresults before libxml2's XML parsing and restore it after parsing.The encoding uses the same technique as URL encoding.
Within XML content, HTML encoding(
) is appropriate, but in this case escaped and unescaped strings are indistinguishable, so it was not possible.In this fix, we added a unit test(in
test_string_util.cpp) for the string manipulation function(test_cr_encoding).Also added
cr_filename.cfor testing filenames containingCRcode. (It was added with C code because it was difficult to create aCRcode file name from the shell script)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.