Skip to content

Commit

Permalink
oleobj.py syntax error
Browse files Browse the repository at this point in the history
In python 3.12+ this escaping is reported as syntax error. Moving the dash to the end of the regex avoids the need for escaping it.

oletools/oleobj.py:537
  /rpmbuild/BUILD/oletools-78b2d459a33df378a4f69ffc6c33313509cecfe4/oletools/oleobj.py:537: SyntaxWarning: invalid escape sequence '\-'
    sane_fname = re.sub(u'[^a-zA-Z0-9.\-_ ]', replacement, basepath)
  • Loading branch information
xambroz authored May 4, 2024
1 parent 78b2d45 commit 6b4c7b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion oletools/oleobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def sanitize_filename(filename, replacement='_',
Might return empty string
"""
basepath = os.path.basename(filename).strip()
sane_fname = re.sub(u'[^a-zA-Z0-9.\-_ ]', replacement, basepath)
sane_fname = re.sub(u'[^a-zA-Z0-9._ -]', replacement, basepath)
sane_fname = str(sane_fname) # py3: does nothing; py2: unicode --> str

while ".." in sane_fname:
Expand Down

0 comments on commit 6b4c7b8

Please # to comment.