Errors with non-ascii characters in 'txt' record

Bug #1350211 reported by Danilo Godec
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pypolicyd-spf
Fix Released
Undecided
Unassigned

Bug Description

OS: openSUSE 13.1
Python: 2.7.6
policyd-spf: 1.3.1

I discovered some errors in my logs:

policyd-spf[11597]: Traceback (most recent call last):
policyd-spf[11597]: File "/usr/bin/policyd-spf", line 680, in <module>
policyd-spf[11597]: instance_dict, configData, peruser)
policyd-spf[11597]: File "/usr/bin/policyd-spf", line 517, in _spfcheck
policyd-spf[11597]: res = spf.check2(ip, sender, helo, querytime=configData.get('Lookup_Time'))
policyd-spf[11597]: File "/usr/lib/python2.7/site-packages/spf.py", line 310, in check2
policyd-spf[11597]: receiver=receiver,timeout=timeout,verbose=verbose,querytime=querytime).check()
policyd-spf[11597]: File "/usr/lib/python2.7/site-packages/spf.py", line 538, in check
policyd-spf[11597]: spf = self.dns_spf(self.d)
policyd-spf[11597]: File "/usr/lib/python2.7/site-packages/spf.py", line 1094, in dns_spf
policyd-spf[11597]: a = [t for t in self.dns_txt(domain) if RE_SPF.match(t)]
policyd-spf[11597]: File "/usr/lib/python2.7/site-packages/spf.py", line 1131, in dns_txt
policyd-spf[11597]: for a in self.dns(domainname, 'TXT')]
policyd-spf[11597]: File "/usr/lib/python2.7/site-packages/spf.py", line 1130, in <genexpr>
policyd-spf[11597]: return [''.join(s.decode("ascii") for s in a)
policyd-spf[11597]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 56: ordinal not in range(128)

I noticed these errors appear for email from specific domains only, so I checked these domains' TXT records and discovered this:

xxxxxxxx.xxx. 6694 IN TXT "v=spf1 mx:mail.xxxxxxxx.xxx ip4:xx.xx.xx.xx \226\128\147all"

I'm pretty sure that the last part (\226\128\147all) is wrong, but perhaps policyd-spf should handle it differently?

Revision history for this message
Scott Kitterman (kitterman) wrote : Re: [Bug 1350211] [NEW] Errors with non-ascii characters in 'txt' record

What version of pyspf do you have? I think the current pyspf won't have that
problem. Note that the actual error:

policyd-spf[11597]: File "/usr/lib/python2.7/site-packages/spf.py", line
1130, in <genexpr>
policyd-spf[11597]: return [''.join(s.decode("ascii") for s in a)
policyd-spf[11597]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
in position 56: ordinal not in range(128)

is in the pyspf module, not in the policy server.

Revision history for this message
Danilo Godec (danci1973) wrote :

pyspf version on my system is 2.0.7, so I upgraded to 2.0.9 now.

Unfortunately the domain that had the problematic SPF record already fixed it and I can't easily test this.

But as the changelog for pyspf 2.0.8 mentions 'Improved unicode error detection in SPF records' I assume the error is fixed.

Revision history for this message
Scott Kitterman (kitterman) wrote :

OK. Please reopen if the problem recurrs.

Changed in pypolicyd-spf:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.