From a9707e0a6f130fc87317cf8d43fbc020db0524ba Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 10 Apr 2022 18:17:20 +0300 Subject: [PATCH] Remove redundant regex escapes --- src/PIL/PdfParser.py | 10 +++++----- src/PIL/XbmImagePlugin.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PIL/PdfParser.py b/src/PIL/PdfParser.py index 9aa0fd6fa..fd5cc5a61 100644 --- a/src/PIL/PdfParser.py +++ b/src/PIL/PdfParser.py @@ -590,7 +590,7 @@ class PdfParser: whitespace_mandatory + rb"trailer" + whitespace_optional - + rb"\<\<(.*\>\>)" + + rb"<<(.*>>)" + newline + rb"startxref" + newline @@ -605,7 +605,7 @@ class PdfParser: whitespace_optional + rb"trailer" + whitespace_optional - + rb"\<\<(.*?\>\>)" + + rb"<<(.*?>>)" + newline + rb"startxref" + newline @@ -659,8 +659,8 @@ class PdfParser: + delimiter_or_ws + rb")" ) - re_dict_start = re.compile(whitespace_optional + rb"\<\<") - re_dict_end = re.compile(whitespace_optional + rb"\>\>" + whitespace_optional) + re_dict_start = re.compile(whitespace_optional + rb"<<") + re_dict_end = re.compile(whitespace_optional + rb">>" + whitespace_optional) @classmethod def interpret_trailer(cls, trailer_data): @@ -719,7 +719,7 @@ class PdfParser: re_array_start = re.compile(whitespace_optional + rb"\[") re_array_end = re.compile(whitespace_optional + rb"]") re_string_hex = re.compile( - whitespace_optional + rb"\<(" + whitespace_or_hex + rb"*)\>" + whitespace_optional + rb"<(" + whitespace_or_hex + rb"*)>" ) re_string_lit = re.compile(whitespace_optional + rb"\(") re_indirect_reference = re.compile( diff --git a/src/PIL/XbmImagePlugin.py b/src/PIL/XbmImagePlugin.py index 15379ce80..59acabeba 100644 --- a/src/PIL/XbmImagePlugin.py +++ b/src/PIL/XbmImagePlugin.py @@ -31,7 +31,7 @@ xbm_head = re.compile( b"#define[ \t]+[^_]*_x_hot[ \t]+(?P[0-9]+)[\r\n]+" b"#define[ \t]+[^_]*_y_hot[ \t]+(?P[0-9]+)[\r\n]+" b")?" - b"[\\000-\\377]*_bits\\[\\]" + rb"[\000-\377]*_bits\[]" )