Type:
Class
Constants:
SPECIALS
:
[ /&(?!#?[\w-]+;)/u, /</u, />/u, /"/u, /'/u, /\r/u ]
The order in which the substitutions occur
SUBSTITUTES
:
['&', '<', '>', '"', ''', ' ']
SLAICEPS
:
[ '<', '>', '"', "'", '&' ]
Characters which are substituted in written strings
SETUTITSBUS
:
[ /</u, />/u, /"/u, /'/u, /&/u ]
NEEDS_A_SECOND_CHECK
:
/(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um
NUMERICENTITY
:
/�*((?:\d+)|(?:x[a-fA-F0-9]+));/
VALID_CHAR
:
[
0x9, 0xA, 0xD,
(0x20..0xD7FF),
(0xE000..0xFFFD),
(0x10000..0x10FFFF)
]
VALID_XML_CHARS
:
Regexp.new('^['+
VALID_CHAR.map { |item|
case item
when Fixnum
[item].pack('U').force_encoding('utf-8')
when Range
[item.first, '-'.ord, item.last].pack('UUU').force_encoding('utf-8')
end
}.join +
']*$')
REFERENCE
:
/#{Entity::REFERENCE}/
EREFERENCE
:
/&(?!#{Entity::NAME};)/
Represents text nodes in an XML document