Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre-Yves David
swh-web
Commits
4128af39
Commit
4128af39
authored
11 months ago
by
Antoine Lambert
Committed by
Antoine Lambert
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
inbound_email/utils: Fix handling of invalid email address header
parent
833fd247
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/web/inbound_email/tests/test_utils.py
+2
-0
2 additions, 0 deletions
swh/web/inbound_email/tests/test_utils.py
swh/web/inbound_email/utils.py
+4
-2
4 additions, 2 deletions
swh/web/inbound_email/utils.py
with
6 additions
and
2 deletions
swh/web/inbound_email/tests/test_utils.py
+
2
−
0
View file @
4128af39
...
...
@@ -39,6 +39,8 @@ def test_extract_recipients():
]
del
message
[
"
To
"
]
# check invalid address header are discarded
message
[
"
x-envelope-to
"
]
=
"
foo
"
assert
utils
.
extract_recipients
(
message
)
==
[
Address
(
addr_spec
=
"
test-recipient-2@example.com
"
),
Address
(
...
...
This diff is collapsed.
Click to expand it.
swh/web/inbound_email/utils.py
+
4
−
2
View file @
4128af39
...
...
@@ -4,7 +4,7 @@
# See top-level LICENSE file for more information
from
dataclasses
import
dataclass
from
email.headerregistry
import
Address
from
email.headerregistry
import
Address
,
AddressHeader
from
email.message
import
EmailMessage
,
Message
import
logging
from
typing
import
List
,
Optional
,
Set
,
Tuple
,
Union
...
...
@@ -48,7 +48,9 @@ def extract_recipients(message: EmailMessage) -> List[Address]:
ret
=
[]
for
header_name
in
HEADERS
:
for
header
in
message
.
get_all
(
header_name
,
[]):
for
header
in
filter
(
lambda
h
:
isinstance
(
h
,
AddressHeader
),
message
.
get_all
(
header_name
,
[])
):
ret
.
extend
(
header
.
addresses
)
return
ret
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment