Skip to content

Commit 521dab9

Browse files
hugovkradarhere
authored andcommitted
Use more specific regex chars to prevent ReDoS
* CVE-2021-25292
1 parent 8b8076b commit 521dab9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/PIL/PdfParser.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,9 @@ def next_object_id(self, offset=None):
580580
whitespace_or_hex = br"[\000\011\012\014\015\0400-9a-fA-F]"
581581
whitespace_optional = whitespace + b"*"
582582
whitespace_mandatory = whitespace + b"+"
583+
whitespace_optional_no_nl = br"[\000\011\014\015\040]*" # no "\012" aka "\n"
583584
newline_only = br"[\r\n]+"
584-
newline = whitespace_optional + newline_only + whitespace_optional
585+
newline = whitespace_optional_no_nl + newline_only + whitespace_optional_no_nl
585586
re_trailer_end = re.compile(
586587
whitespace_mandatory
587588
+ br"trailer"

0 commit comments

Comments
 (0)