diff --git a/.travis.yml b/.travis.yml index 1ac3030..8f05d83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,11 +13,11 @@ matrix: - python: 3.8 env: REQ="https://github.com/django/django/archive/master.zip#egg=Django" - python: 3.8 - env: REQ="Django>=3.1rc1,<3.2" + env: REQ="Django>=3.1,<3.2" - python: 3.7 - env: REQ="Django>=3.1rc1,<3.2" + env: REQ="Django>=3.1,<3.2" - python: 3.6 - env: REQ="Django>=3.1rc1,<3.2" + env: REQ="Django>=3.1,<3.2" - python: 3.7 env: REQ="Django>=3.0,<3.1" - python: 3.6 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fdb58d8..7958033 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,8 @@ Change log - Fixed an ``authlib.admin_oauth`` crash when fetching user data fails. - Replaced ``ugettext*`` with ``gettext*``. - Replaced ``url()`` with ``re_path()``. +- Fixed a crash when creating ``little_auth`` users with invalid email + addresses. `0.9`_ (2019-02-09) diff --git a/authlib/little_auth/models.py b/authlib/little_auth/models.py index eef3a60..e62f9e7 100644 --- a/authlib/little_auth/models.py +++ b/authlib/little_auth/models.py @@ -5,7 +5,7 @@ def _obfuscate(email): - user, domain = email.rsplit("@", 1) + user, _sep, domain = email.partition("@") return "%s%s@***.%s" % ( user[:3], "***" if len(user) > 3 else "", diff --git a/tests/testapp/test_authlib.py b/tests/testapp/test_authlib.py index e276e31..3fb4afe 100644 --- a/tests/testapp/test_authlib.py +++ b/tests/testapp/test_authlib.py @@ -145,6 +145,11 @@ def test_login(self): ) self.assertRedirects(response, "/?login=1", fetch_redirect_response=False) + def test_strange_email(self): + user = User(email="no-email") + self.assertEqual(user.get_full_name(), "no-***@***") + self.assertEqual(str(user), "no-***@***") + class OAuth2Test(TestCase): def test_oauth2_authorization_redirect(self):