From 3e5ef6e9fd1350deafdb59ca856f500359abd1d3 Mon Sep 17 00:00:00 2001
From: Wleeaf <179125857+wleeaf@users.noreply.github.com>
Date: Sat, 24 Oct 2026 22:59:55 +0000
Subject: [PATCH] Accept combining characters and extenders in element and
attribute names
NCNAME_STR left COMBININGCHAR and EXTENDER as TODO, so names whose non-first characters are combining marks that are not [:alpha:] (U+0301 in a decomposed "cafe\u0301", the Thai U+0E4C, the Devanagari virama U+094D, the Tamil U+0BCD) or the middle dot U+00B7 ("col\u00B7leccio") raised ParseException, although REXML::Element.new accepts these names and writes them. Add the combining marks that [:alpha:] does not already include, and the two Extender characters that are not [:alpha:].
---
lib/rexml/parsers/baseparser.rb | 6 ++++--
test/parse/test_element.rb | 14 ++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
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("