From 71eb7512c1eb581e0959d82b19e5868b87790a68 Mon Sep 17 00:00:00 2001 From: g4lb Date: Sun, 29 Nov 2026 10:33:23 +0200 Subject: [PATCH] Hoist entity name regexp in Text.check --- lib/rexml/text.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb index 7e31046c..0119dacb 100644 --- a/lib/rexml/text.rb +++ b/lib/rexml/text.rb @@ -21,6 +21,7 @@ class Text < Child attr_accessor :raw NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um + ENTITY_NAME_PATTERN = /\A#{Entity::NAME}\z/um NUMERICENTITY = /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ VALID_CHAR = [ 0x9, 0xA, 0xD, @@ -157,7 +158,7 @@ def Text.check string, pattern, doctype = nil else raise "Illegal character #{string.inspect} in raw string #{string.inspect}" end - elsif !(/\A#{Entity::NAME}\z/um.match?(value)) + elsif !(ENTITY_NAME_PATTERN.match?(value)) raise "Illegal character \"#{string[index]}\" in raw string #{string.inspect}" end