Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize author name unicode before matching #2006

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions poetry/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from contextlib import contextmanager
from typing import Union
from warnings import warn
from unicodedata import normalize

from poetry.semver import Version
from poetry.semver import parse_constraint
Expand Down Expand Up @@ -160,7 +161,7 @@ def _get_author(self): # type: () -> dict
if not self._authors:
return {"name": None, "email": None}

m = AUTHOR_REGEX.match(self._authors[0])
m = AUTHOR_REGEX.match(normalize("NFC", self._authors[0]))

name = m.group("name")
email = m.group("email")
Expand All @@ -171,7 +172,7 @@ def _get_maintainer(self): # type: () -> dict
if not self._maintainers:
return {"name": None, "email": None}

m = AUTHOR_REGEX.match(self._maintainers[0])
m = AUTHOR_REGEX.match(normalize("NFC", self._maintainers[0]))

name = m.group("name")
email = m.group("email")
Expand Down
8 changes: 8 additions & 0 deletions tests/packages/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def test_package_authors():
assert package.author_name == "Sébastien Eustace"
assert package.author_email == "[email protected]"

package.authors.insert(0, "Raphaël Yancey <[email protected]>") # With combining diacritics (ë = e + ¨ = e\u0308)
assert package.author_name == "Raphaël Yancey" # Is normalized into \u00EB
assert package.author_email == "[email protected]"

package.authors.insert(0, "Raphaël Yancey <[email protected]>") # Without (ë = \u00EB)
assert package.author_name == "Raphaël Yancey"
assert package.author_email == "[email protected]"

package.authors.insert(0, "John Doe")
assert package.author_name == "John Doe"
assert package.author_email is None
Expand Down