Repository navigation
fix: don't truncate filenames containing "?" or "#" in local paths - #227
Closed
rahul05ranjan wants to merge 1 commit into
Closed
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
get_filename applied urlsplit to every input, so "?" and "#" were treated as URL query/fragment delimiters even for filesystem paths, truncating the filename and dropping its extension. Apply urlsplit only when the input parses as a URL with a scheme, so local paths keep their "?" / "#" characters while URL handling remains unchanged. Fixes fabiocaccamo#226 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
=======================================
Coverage 98.52% 98.52%
=======================================
Files 13 13
Lines 812 815 +3
=======================================
+ Hits 800 803 +3
Misses 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Closing as duplicate of #204. This approach also misdetects Windows drive paths as URLs ( |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
get_filenameran every input throughurllib.parse.urlsplit, so the characters?and#— legal in filenames on Linux and macOS — were treated as URL query/fragment delimiters even for local paths, silently truncating the filename and dropping its extension:Because operations like
move_file,rename_file,rename_file_extensionandtransform_filepathbuild onget_filename, movingfile?v1.txtactually renames the file tofile, losing the extension.Why This Change Was Made
urlsplitis now applied only when the input actually parses as a URL with a scheme; plain filesystem paths are handled byos.path.basenameonly. URL behavior is unchanged (e.g.get_filename("https://domain.com/Document.txt?p=1") == "Document.txt"still holds, including when the string has already been normalized by callers likesplit_filename).User Impact
?or#keep their name and extension throughmove_file/rename_*/transform_filepath.Evidence
New assertions in
test_get_filenameand the new regression testtest_move_file_with_special_chars_in_filenamefail onmainand pass with this change; the full test suite passes (the two umask-dependent failures on the dev machine are pre-existing and unrelated).Fixes #226