Skip to content

Commit 74237a7

Browse files
authored
Merge pull request #28 from nexB/preserve_spaces_in_filenames_for_extracted_files
Call paths.safe_path using preserve_spaces argument
2 parents 632f6a8 + d753aa2 commit 74237a7

20 files changed

+1505
-1500
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Changelog
44
v (next)
55
--------
66

7+
- Spaces in filenames are no longer replaced by underscores when files are
8+
extracted from archives.
79

810
v21.6.2
911
-------

src/extractcode/libarchive2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def extract(location, target_dir, skip_symlinks=True):
203203
if TRACE:
204204
logger.debug(' writing.....')
205205

206-
_target_path = entry.write(abs_target_dir, transform_path=paths.safe_path)
206+
_target_path = entry.write(abs_target_dir, transform_path=partial(paths.safe_path, preserve_spaces=True))
207207

208208
return warnings
209209

src/extractcode/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def extract(location, target_dir):
5454

5555
# make the path safe to use as a subfile path
5656
# ensure this a good and clean posix relative path
57-
patch_subfile_path = paths.safe_path(patch_subfile_path)
57+
patch_subfile_path = paths.safe_path(patch_subfile_path, preserve_spaces=True)
5858

5959
# create directories
6060
parent_dir = posixpath.dirname(patch_subfile_path)

src/extractcode/sevenzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def extract_file_by_file(
467467
errors[entry.path] = 'No file name extracted.'
468468
continue
469469

470-
safe_path = paths.safe_path(entry.path, posix=True)
470+
safe_path = paths.safe_path(entry.path, posix=True, preserve_spaces=True)
471471
target_file_loc = os.path.join(target_dir, safe_path)
472472
target_file_dir = os.path.dirname(target_file_loc)
473473
fileutils.create_dir(target_file_dir)

0 commit comments

Comments
 (0)