From 6b4c7b8e093fc10a6223fb4ca694fa0dde07ea6d Mon Sep 17 00:00:00 2001 From: Michal Ambroz <723625+xambroz@users.noreply.github.com> Date: Sat, 4 May 2024 17:07:00 +0200 Subject: [PATCH] oleobj.py syntax error 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) --- oletools/oleobj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oletools/oleobj.py b/oletools/oleobj.py index eef96b66..e4a43359 100644 --- a/oletools/oleobj.py +++ b/oletools/oleobj.py @@ -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: