Skip to content

Commit

Permalink
Update for pythonGH-104802: don't register dot defect if there is a s…
Browse files Browse the repository at this point in the history
…ingle cwf

Don't add new error cases when refactoring; simply ensure that the code avoids an IndexError for the cases it attempts to handle
  • Loading branch information
fsc-eriker authored and zware committed Feb 14, 2024
1 parent 73b050e commit 03efb0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/email/_header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,14 +1519,14 @@ def get_obs_local_part(value):
else:
if (obs_local_part[0].token_type == 'dot'
or (obs_local_part[0].token_type=='cfws'
and len(obs_local_part) == 1
or obs_local_part[1].token_type=='dot')):
and len(obs_local_part) > 1
and obs_local_part[1].token_type=='dot')):
obs_local_part.defects.append(errors.InvalidHeaderDefect(
"Invalid leading '.' in local part"))
if (obs_local_part[-1].token_type == 'dot'
or (obs_local_part[-1].token_type=='cfws'
and len(obs_local_part) == 1
or obs_local_part[-2].token_type=='dot')):
and len(obs_local_part) > 1
and obs_local_part[-2].token_type=='dot')):
obs_local_part.defects.append(errors.InvalidHeaderDefect(
"Invalid trailing '.' in local part"))
if obs_local_part.defects:
Expand Down

0 comments on commit 03efb0d

Please sign in to comment.