Skip to content

Commit

Permalink
fix: Allow non-ASCII values in all attributes
Browse files Browse the repository at this point in the history
PR #1017 allowed Unicord characters everywhere.
This fixes a bug that xml2rfc was guarding against non-ASCII characters
in attribute values.
With `--warn-bare-unicode`, xml2rfc will warn if non-ASCII characters are
present in attribute values.

Fixes #1105
  • Loading branch information
kesara committed Feb 19, 2024
1 parent ec6d921 commit 1e21000
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
9 changes: 0 additions & 9 deletions xml2rfc/util/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@
('xref', 'derivedContent'),
}

latinscript_attributes = {
('author', 'asciiFullname'),
('author', 'asciiSurname'),
('author', 'asciiInitials'),
('contact', 'asciiFullname'),
('contact', 'asciiSurname'),
('contact', 'asciiInitials'),
}

# These unicode tags don't require an ascii attribute
bare_unicode_tags = set([
'artwork',
Expand Down
9 changes: 3 additions & 6 deletions xml2rfc/writers/preptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from xml2rfc.util.num import ol_style_formatter
from xml2rfc.util.unicode import (
unicode_content_tags, unicode_attributes, expand_unicode_element,
isascii, latinscript_attributes, is_svg)
isascii, is_svg)
from xml2rfc.utils import build_dataurl, namespaces, sdict, clean_text
from xml2rfc.writers.base import default_options, BaseV3Writer, RfcWriterError

Expand Down Expand Up @@ -436,12 +436,9 @@ def check_attribute_values(self, e, p):
for a in c.attrib:
v = c.get(a)
if not (c.tag, a) in unicode_attributes:
if (c.tag, a) in latinscript_attributes:
if not is_script(v, 'Latin'):
self.err(c, 'Found non-Latin-script content in <%s> attribute value %s="%s"' % (c.tag, a, v))
else:
if self.options.warn_bare_unicode:
if not isascii(v):
self.err(c, 'Found non-ASCII content in <%s> attribute value %s="%s"' % (c.tag, a, v))
self.warn(c, f'Found non-ASCII content in {c.tag} attribute value {a}="{v}" that should be inspected to ensure they are intentional.')
if not (c.tag, a) in space_attributes:
vv = v.strip()
if vv != v:
Expand Down

0 comments on commit 1e21000

Please sign in to comment.