File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2398,18 +2398,21 @@ def get_section(value):
23982398 The caller should already have dealt with leading CFWS.
23992399
24002400 """
2401+ def is_ascii_digit (d ):
2402+ # We don't use str.isdigit because only ASCII digits are allowed.
2403+ return '0' <= d <= '9'
2404+
24012405 section = Section ()
24022406 if not value or value [0 ] != '*' :
24032407 raise errors .HeaderParseError ("Expected section but found {}" .format (
24042408 value ))
24052409 section .append (ValueTerminal ('*' , 'section-marker' ))
24062410 value = value [1 :]
2407- # We don't use str.isdigit because only ASCII digits are allowed.
2408- if not value or not ('0' <= value [0 ] <= '9' ):
2411+ if not value or not is_ascii_digit (value [0 ]):
24092412 raise errors .HeaderParseError ("Expected section number but "
24102413 "found {}" .format (value ))
24112414 digits = ''
2412- while value and ( '0' <= value [0 ] <= '9' ):
2415+ while value and is_ascii_digit ( value [0 ]):
24132416 digits += value [0 ]
24142417 value = value [1 :]
24152418 if digits [0 ] == '0' and digits != '0' :
You can’t perform that action at this time.
0 commit comments