From 3a5844fef8c1273fff0839dc313f22c9183da4d4 Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Fri, 11 Jul 2014 00:20:33 -0700 Subject: [PATCH] Updated address length check to 1024 characters because many unsubscribe links were much larger than our old limit (which was already 4x the RFC limit). New limit is 16x the RFC limit. Bumped the version of dnsq and expiringdict. Moved mock and nose from install_requires to tests_require. --- flanker/addresslib/parser.py | 8 ++++---- setup.py | 12 +++++++----- tests/addresslib/parser_mailbox_test.py | 2 +- tests/fixtures/mailbox_invalid.txt | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/flanker/addresslib/parser.py b/flanker/addresslib/parser.py index 4c2ac61..509e7a4 100644 --- a/flanker/addresslib/parser.py +++ b/flanker/addresslib/parser.py @@ -185,11 +185,11 @@ class _AddressParser(object): "Additional post processing checks to ensure mailbox is valid." parts = address.split('@') - # check if local part is less than 256 octets, the actual - # limit is 64 octets but we quadruple the size here because + # check if local part is less than 1024 octets, the actual + # limit is 64 octets but we allow 16x that size here because # unsubscribe links are frequently longer lpart = parts[0] - if len(lpart) > 256: + if len(lpart) > 1024: return False # check if the domain is less than 255 octets @@ -611,6 +611,6 @@ class ParserException(Exception): -MAX_ADDRESS_LENGTH = 512 +MAX_ADDRESS_LENGTH = 1280 MAX_ADDRESS_NUMBER = 1024 MAX_ADDRESS_LIST_LENGTH = MAX_ADDRESS_LENGTH * MAX_ADDRESS_NUMBER diff --git a/setup.py b/setup.py index 4cd3b9a..e913f9c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages setup(name='flanker', - version='0.4.14', + version='0.4.15', description='Mailgun Parsing Tools', long_description=open('README.rst').read(), classifiers=[], @@ -17,12 +17,14 @@ setup(name='flanker', packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=True, + tests_require=[ + 'nose', + 'mock' + ], install_requires=[ 'chardet>=1.0.1', - 'dnsq>=1.1', - 'expiringdict>=1.1', - 'mock>=1.0.1', - 'nose>=1.2.1', + 'dnsq>=1.1.3', + 'expiringdict>=1.1.2', 'Paste>=1.7.5', 'redis>=2.7.1', # IMPORTANT! Newer regex versions are a lot slower for diff --git a/tests/addresslib/parser_mailbox_test.py b/tests/addresslib/parser_mailbox_test.py index 4650831..3ea39d1 100644 --- a/tests/addresslib/parser_mailbox_test.py +++ b/tests/addresslib/parser_mailbox_test.py @@ -469,7 +469,7 @@ def test_local_part(): # test length limits run_mailbox_test(''.join(['a'*128, '@b']), ''.join(['a'*128, '@b'])) - run_mailbox_test(''.join(['a'*257, '@b']), None) + run_mailbox_test(''.join(['a'*1025, '@b']), None) # because qtext and quoted-pair are longer than 64 bytes (limit on local-part) # we use a sample in testing, every other for qtext and every fifth for quoted-pair diff --git a/tests/fixtures/mailbox_invalid.txt b/tests/fixtures/mailbox_invalid.txt index 2c43063..fded219 100644 --- a/tests/fixtures/mailbox_invalid.txt +++ b/tests/fixtures/mailbox_invalid.txt @@ -21,7 +21,7 @@ this\ still\"not\\allowed@example.com first.last@sub.do,com first\@last@iana.org first.last -12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912345678912@iana.org +01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234@example.com .first.last@iana.org first.last.@iana.org first..last@iana.org -- 2.43.0