mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Removing newlines from file titles.
This commit is contained in:
parent
7c5caf1dfd
commit
7de8275942
2 changed files with 7 additions and 2 deletions
|
|
@ -774,12 +774,12 @@ def get_files_and_directories(directory: Path):
|
|||
|
||||
|
||||
# These characters are invalid in Windows or Linux.
|
||||
INVALID_FILE_CHARS = re.compile(r'[/<>:\|"\\\?\*%!]')
|
||||
INVALID_FILE_CHARS = re.compile(r'[/<>:\|"\\\?\*%!\n\r]')
|
||||
|
||||
|
||||
def escape_file_name(name: str) -> str:
|
||||
"""Remove any invalid characters in a file name."""
|
||||
return INVALID_FILE_CHARS.sub('', name)
|
||||
return INVALID_FILE_CHARS.sub('', name).strip()
|
||||
|
||||
|
||||
def native_only(func: callable):
|
||||
|
|
|
|||
|
|
@ -284,6 +284,11 @@ def test_zig_zag(low, high, expected):
|
|||
('foo&', 'foo&'),
|
||||
('foo%', 'foo'),
|
||||
('foo!', 'foo'),
|
||||
('fo\no', 'foo'),
|
||||
('fo\ro', 'foo'),
|
||||
('foo\r', 'foo'),
|
||||
('foo\r', 'foo'),
|
||||
('foo ', 'foo'),
|
||||
]
|
||||
)
|
||||
def test_escape_file_name(name, expected):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue