Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
aeff1f8a
Commit
aeff1f8a
authored
16 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Skip source route in parseaddr.
parent
a7bd7b71
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Milter/utils.py
+21
-2
21 additions, 2 deletions
Milter/utils.py
pymilter.spec
+3
-0
3 additions, 0 deletions
pymilter.spec
with
24 additions
and
2 deletions
Milter/utils.py
+
21
−
2
View file @
aeff1f8a
## @package Milter.utils
# Miscellaneous functions.
#
import
re
import
struct
import
socket
...
...
@@ -11,7 +15,7 @@ ip4re = re.compile(r'^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$')
# from spf.py
def
addr2bin
(
str
):
"
Convert a string IPv4 address into an unsigned integer.
"
""
"
Convert a string IPv4 address into an unsigned integer.
"
""
return
struct
.
unpack
(
"
!L
"
,
socket
.
inet_aton
(
str
))[
0
]
MASK
=
0xFFFFFFFF
L
...
...
@@ -42,6 +46,10 @@ def iniplist(ipaddr,iplist):
return
True
return
False
## Split email into Fullname and address.
# This replaces <code>email.Utils.parseaddr</code> but fixes
# some <a href="http://bugs.python.org/issue1025395">tricky test cases</a>.
#
def
parseaddr
(
t
):
"""
Split email into Fullname and address.
...
...
@@ -91,13 +99,24 @@ def parse_addr(t):
[
'
user@bar
'
,
'
example.com
'
]
>>>
parse_addr
(
'
foo
'
)
[
'
foo
'
]
>>>
parse_addr
(
'
@mx.example.com:user@example.com
'
)
[
'
user
'
,
'
example.com
'
]
"""
if
t
.
startswith
(
'
<
'
)
and
t
.
endswith
(
'
>
'
):
t
=
t
[
1
:
-
1
]
if
t
.
startswith
(
'"'
):
if
t
.
endswith
(
'"'
):
return
[
t
[
1
:
-
1
]]
pos
=
t
.
find
(
'"
@
'
)
if
pos
>
0
:
return
[
t
[
1
:
pos
],
t
[
pos
+
2
:]]
return
t
.
split
(
'
@
'
)
if
t
.
startswith
(
'
@
'
):
t
=
t
.
split
(
'
:
'
,
1
)[
1
]
return
t
.
rsplit
(
'
@
'
,
1
)
## Decode headers gratuitously encoded to hide the content.
# Spammers often encode headers to obscure the content from
# spam filters. This function decodes gratuitously encoded
# headers.
# @param val the raw header value
# @return the decoded value or the original raw value
def
parse_header
(
val
):
"""
Decode headers gratuitously encoded to hide the content.
...
...
This diff is collapsed.
Click to expand it.
pymilter.spec
+
3
−
0
View file @
aeff1f8a
...
...
@@ -83,6 +83,9 @@ chmod a+x $RPM_BUILD_ROOT%{libdir}/start.sh
rm -rf $RPM_BUILD_ROOT
%changelog
* Thu Jul 02 2009 Stuart Gathman <stuart@bmsi.com> 0.9.3-1
- Handle source route in Milter.util.parse_addr()
* Tue Jun 02 2009 Stuart Gathman <stuart@bmsi.com> 0.9.2-3
- Change result of @noreply callbacks to NOREPLY when so negotiated.
...
...
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