-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Description
Feature or enhancement
Proposal:
while value and value[0] != ';':
try:
token, value = get_mailbox(value)
mailbox_list.append(token)
except errors.HeaderParseError:
leader = None
Each iteration of the loop is accompanied by assigning the value None to the leader variable, so
else:
token, value = get_invalid_mailbox(value, ',;')
if leader is not None:
token[:0] = [leader]
mailbox_list.append(token)
mailbox_list.defects.append(errors.InvalidHeaderDefect(
"invalid mailbox in mailbox-list"))
the code will not be executed after checking leader for None. because the value of the leader variable will not change from the moment of the initial assignment until the else block is called.
Link to the method code:
cpython/Lib/email/_header_value_parser.py
Line 1855 in 180b3eb
def get_mailbox_list(value): |
Same situation was found here:
cpython/Lib/email/_header_value_parser.py
Line 2008 in 180b3eb
def get_address_list(value): |
Specifically:
while value:
try:
token, value = get_address(value)
address_list.append(token)
except errors.HeaderParseError:
leader = None
The leader variable has been set to NULL...
else:
token, value = get_invalid_mailbox(value, ',')
if leader is not None:
token[:0] = [leader]
address_list.append(Address([token]))
address_list.defects.append(errors.InvalidHeaderDefect(
"invalid address in address-list"))
...which has not changed at the time the else block was executed. This behavior occurs at each iteration of the loop.
I will try to form a pull request for correction.
Found by Linux Verification Center with SVACE
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response