Skip to content

Commit

Permalink
Merge pull request #167 from mailgun/brendan/dont-quote-periods
Browse files Browse the repository at this point in the history
Don't quote periods in display names
  • Loading branch information
b0d0nne11 authored Jul 14, 2017
2 parents 0dce0f9 + a66a7a7 commit 2f24c68
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion flanker/addresslib/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flanker.addresslib.lexer import t_ATOM, t_FWSP

_RE_ATOM_PHRASE = re.compile(
r'({atom}({fwsp}{atom})*)?'.format(atom=t_ATOM, fwsp=t_FWSP),
r'(({atom}|\.)+({fwsp}({atom}|\.)+)*)?'.format(atom=t_ATOM, fwsp=t_FWSP),
re.MULTILINE | re.VERBOSE)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

setup(name='flanker',
version='0.7.2',
version='0.7.3',
description='Mailgun Parsing Tools',
long_description=open('README.rst').read(),
classifiers=[],
Expand Down
34 changes: 31 additions & 3 deletions tests/addresslib/address_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_edge_cases():
def test_display_name__to_full_spec():
eq_('"foo (\\"bar\\") blah" <[email protected]>',
EmailAddress('foo ("bar") blah', '[email protected]').full_spec())
eq_('"foo. bar" <[email protected]>',
eq_('foo. bar <[email protected]>',
EmailAddress('foo. bar', '[email protected]').full_spec())
eq_('"\\"\\"" <[email protected]>',
EmailAddress('""', '[email protected]').full_spec()),
Expand Down Expand Up @@ -372,7 +372,21 @@ def test_address_convertible_2_ascii():
'unicode': u'Федот <[email protected]ñ>',
'full_spec': '=?utf-8?b?0KTQtdC00L7Rgg==?= <[email protected]>',
}, {
'desc': 'display_name=quoted-utf8-with-specials, domain=ascii',
'desc': 'display_name=quoted-utf8-with-period, domain=ascii',
'addr': u'"Федот . Стрелец" <[email protected]>',

'display_name': u'Федот . Стрелец',
'ace_display_name': '=?utf-8?b?0KTQtdC00L7RgiAuINCh0YLRgNC10LvQtdGG?=',
'hostname': u'bar.com',
'ace_hostname': 'bar.com',
'address': u'[email protected]',
'ace_address': '[email protected]',
'repr': 'Федот . Стрелец <[email protected]>',
'str': '[email protected]',
'unicode': u'Федот . Стрелец <[email protected]>',
'full_spec': '=?utf-8?b?0KTQtdC00L7RgiAuINCh0YLRgNC10LvQtdGG?= <[email protected]>',
}, {
'desc': 'display_name=quoted-utf8-with-special, domain=ascii',
'addr': u'"Федот @ Стрелец" <[email protected]>',

'display_name': u'Федот @ Стрелец',
Expand All @@ -386,7 +400,21 @@ def test_address_convertible_2_ascii():
'unicode': u'"Федот @ Стрелец" <[email protected]>',
'full_spec': '=?utf-8?b?ItCk0LXQtNC+0YIgQCDQodGC0YDQtdC70LXRhiI=?= <[email protected]>',
}, {
'desc': 'display_name=quoted-and-encoded-utf8-with-specials, domain=ascii',
'desc': 'display_name=quoted-and-encoded-utf8-with-period, domain=ascii',
'addr': u'=?utf-8?b?ItCk0LXQtNC+0YIgLiDQodGC0YDQtdC70LXRhiI=?= <[email protected]>',

'display_name': u'Федот . Стрелец',
'ace_display_name': '=?utf-8?b?0KTQtdC00L7RgiAuINCh0YLRgNC10LvQtdGG?=',
'hostname': u'bar.com',
'ace_hostname': 'bar.com',
'address': u'[email protected]',
'ace_address': '[email protected]',
'repr': 'Федот . Стрелец <[email protected]>',
'str': '[email protected]',
'unicode': u'Федот . Стрелец <[email protected]>',
'full_spec': '=?utf-8?b?0KTQtdC00L7RgiAuINCh0YLRgNC10LvQtdGG?= <[email protected]>',
}, {
'desc': 'display_name=quoted-and-encoded-utf8-with-special, domain=ascii',
'addr': u'=?utf-8?b?ItCk0LXQtNC+0YIgQCDQodGC0YDQtdC70LXRhiI=?= <[email protected]>',

'display_name': u'Федот @ Стрелец',
Expand Down
5 changes: 4 additions & 1 deletion tests/addresslib/quote_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ def test_quote():
eq_('"foo< bar"', smart_quote('foo< bar'))
eq_('"foo> bar"', smart_quote('foo> bar'))
eq_('"foo\\" bar"', smart_quote('foo" bar'))
eq_('"foo. bar"', smart_quote('foo. bar'))
eq_('"foo: bar"', smart_quote('foo: bar'))


def test_quote__periods():
eq_('foo. bar', smart_quote('foo. bar'))


def test_quote__spaces():
eq_('foo bar', smart_quote('foo bar'))
eq_('" foo bar"', smart_quote(' foo bar'))
Expand Down

0 comments on commit 2f24c68

Please sign in to comment.