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
3ad67bd3
Commit
3ad67bd3
authored
19 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Ignore records missing spaces.
parent
eb2e730b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
spf.py
+15
-4
15 additions, 4 deletions
spf.py
with
15 additions
and
4 deletions
spf.py
+
15
−
4
View file @
3ad67bd3
...
...
@@ -47,6 +47,9 @@ For news, bugfixes, etc. visit the home page for this implementation at
# Terrence is not responding to email.
#
# $Log$
# Revision 1.14 2005/08/12 17:36:51 customdesigned
# Trean non-existant include as no match in "lax" mode.
#
# Revision 1.13 2005/07/22 16:00:23 customdesigned
# Limit CNAME chains independently of DNS lookup limit
#
...
...
@@ -285,6 +288,10 @@ def DNSLookup(name,qtype):
except
DNS
.
DNSError
,
x
:
raise
TempError
,
'
DNS
'
+
str
(
x
)
def
isSPF
(
txt
):
"
Return True if txt has SPF record signature.
"
return
txt
.
startswith
(
'
v=spf1
'
)
or
txt
==
'
v=spf1
'
# 32-bit IPv4 address mask
MASK
=
0xFFFFFFFF
L
...
...
@@ -590,7 +597,11 @@ class query(object):
# split string by whitespace, drop the 'v=spf1'
#
spf
=
spf
.
split
()[
1
:]
spf
=
spf
.
split
()
#Catch case where SPF record has no spaces
if
spf
[
0
]
!=
'
v=spf1
'
:
raise
PermError
(
'
Invalid SPF record in
'
,
self
.
d
)
spf
=
spf
[
1
:]
# copy of explanations to be modified by exp=
exps
=
self
.
exps
...
...
@@ -815,11 +826,11 @@ class query(object):
is found.
"""
# for performance, check for most common case of TXT first
a
=
[
t
for
t
in
self
.
dns_txt
(
domain
)
if
t
.
startswith
(
'
v=spf1
'
)]
a
=
[
t
for
t
in
self
.
dns_txt
(
domain
)
if
isSPF
(
t
)]
if
len
(
a
)
==
1
and
self
.
strict
<
2
:
return
a
[
0
]
# check official SPF type first when it becomes more popular
b
=
[
t
for
t
in
self
.
dns_99
(
domain
)
if
t
.
startswith
(
'
v=spf1
'
)]
b
=
[
t
for
t
in
self
.
dns_99
(
domain
)
if
isSPF
(
t
)]
if
len
(
b
)
==
1
:
# FIXME: really must fully parse each record
# and compare with appropriate parts case insensitive.
...
...
@@ -832,7 +843,7 @@ class query(object):
if
DELEGATE
:
# use local record if neither found
a
=
[
t
for
t
in
self
.
dns_txt
(
domain
+
'
._spf.
'
+
DELEGATE
)
if
t
.
startswith
(
'
v=spf1
'
)
if
isSPF
(
t
)
]
if
len
(
a
)
==
1
:
return
a
[
0
]
return
None
...
...
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