pyemailprotectionslib icon indicating copy to clipboard operation
pyemailprotectionslib copied to clipboard

Error when there are special characters in the TXT registers

Open mauroka opened this issue 9 years ago • 0 comments

Hello, when there are special characters in the TXT registers there is an error in Resolver.py You can check with the following domain: ./spoofcheck.py one.gob.do UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)

The solution: Add the following lines to Resolver.py after import sys: reload(sys) sys.setdefaultencoding('utf-8')

The complete error: Traceback (most recent call last): File "./spoofcheck.py", line 218, in spf_record_strength = is_spf_record_strong(domain) File "./spoofcheck.py", line 97, in is_spf_record_strong spf_record = spflib.SpfRecord.from_domain(domain) File "/venv/lib/python2.7/site-packages/emailprotectionslib/spf.py", line 126, in from_domain spf_string = get_spf_string_for_domain(domain) File "/venv/lib/python2.7/site-packages/emailprotectionslib/spf.py", line 188, in get_spf_string_for_domain txt_records = Resolver.resolver().query(domain, query_type="TXT") File "/venv/lib/python2.7/site-packages/emailprotectionslib/Resolver.py", line 46, in query ret.append((rhost, rtype, str(r.rdata)))

mauroka avatar Mar 21 '17 14:03 mauroka