Skip to content

Commit 5a862b2

Browse files
authored
feat: Append ascii name if any 8bit UTF8 chars (#9173)
Fixes: 7167
1 parent 0e2df84 commit 5a862b2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ietf/utils/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,14 @@ def test_render_author_name(self):
709709
)),
710710
"Joanna Q. Public",
711711
)
712+
self.assertEqual(
713+
XMLDraft.render_author_name(lxml.etree.Element(
714+
"author",
715+
fullname=chr(340)+"ich",
716+
asciiFullname="Rich UTF-8",
717+
)),
718+
chr(340)+"ich (Rich UTF-8)",
719+
)
712720
self.assertEqual(
713721
XMLDraft.render_author_name(lxml.etree.Element(
714722
"author",

ietf/utils/xmldraft.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ def render_author_name(author_elt):
233233
# Use fullname attribute, if present
234234
fullname = author_elt.attrib.get("fullname", "").strip()
235235
if fullname:
236+
# If any 8bit chars in the fullname, try to append the author's
237+
# name in ascii.
238+
if any([x >= 0x80 for x in fullname.encode('utf8')]):
239+
asciifullname = author_elt.attrib.get("asciiFullname", "").strip()
240+
if asciifullname:
241+
fullname = fullname + ' (' + asciifullname + ')'
236242
return fullname
237243
surname = author_elt.attrib.get("surname", "").strip()
238244
initials = author_elt.attrib.get("initials", "").strip()

0 commit comments

Comments
 (0)