diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index d87f281d..06e8025f 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -59,8 +59,10 @@ class BaseParser LETTER = '[:alpha:]' DIGIT = '[:digit:]' - COMBININGCHAR = '' # TODO - EXTENDER = '' # TODO + # Only the ones that aren't [:alpha:], to avoid duplicated ranges in + # the NCNAME_STR character class + COMBININGCHAR = '[\p{M}&&[^[:alpha:]]]' + EXTENDER = '\u00B7\u0387' NCNAME_STR= "[#{LETTER}_][-[:alnum:]._#{COMBININGCHAR}#{EXTENDER}]*" QNAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})" diff --git a/test/parse/test_element.rb b/test/parse/test_element.rb index d1c1c8d3..7c115e18 100644 --- a/test/parse/test_element.rb +++ b/test/parse/test_element.rb @@ -164,6 +164,20 @@ def test_after_empty_element_tag_root end end + def test_combining_character_in_name + # U+0301 COMBINING ACUTE ACCENT + document = parse("") + assert_equal(["cafe\u0301", "1"], + [document.root.name, + document.root.attributes["e\u0301t\u0301e\u0301"]]) + end + + def test_extender_in_name + # U+00B7 MIDDLE DOT + document = parse("") + assert_equal("col\u00B7leccio", document.root.name) + end + def test_linear_performance_attribute_value_gt seq = [10000, 50000, 100000, 150000, 200000] assert_linear_performance(seq, rehearsal: 10) do |n|