Skip to content

Commit 03efb0d

Browse files
fsc-erikerzware
authored andcommitted
Update for pythonGH-104802: don't register dot defect if there is a single cwf
Don't add new error cases when refactoring; simply ensure that the code avoids an IndexError for the cases it attempts to handle
1 parent 73b050e commit 03efb0d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/email/_header_value_parser.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1519,14 +1519,14 @@ def get_obs_local_part(value):
15191519
else:
15201520
if (obs_local_part[0].token_type == 'dot'
15211521
or (obs_local_part[0].token_type=='cfws'
1522-
and len(obs_local_part) == 1
1523-
or obs_local_part[1].token_type=='dot')):
1522+
and len(obs_local_part) > 1
1523+
and obs_local_part[1].token_type=='dot')):
15241524
obs_local_part.defects.append(errors.InvalidHeaderDefect(
15251525
"Invalid leading '.' in local part"))
15261526
if (obs_local_part[-1].token_type == 'dot'
15271527
or (obs_local_part[-1].token_type=='cfws'
1528-
and len(obs_local_part) == 1
1529-
or obs_local_part[-2].token_type=='dot')):
1528+
and len(obs_local_part) > 1
1529+
and obs_local_part[-2].token_type=='dot')):
15301530
obs_local_part.defects.append(errors.InvalidHeaderDefect(
15311531
"Invalid trailing '.' in local part"))
15321532
if obs_local_part.defects:

0 commit comments

Comments
 (0)