File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ class ParserState
4747 */
4848 private $ iLineNo ;
4949
50+ /**
51+ * @var array<string, bool>
52+ */
53+ private $ identifierEscapeFreeCache = [];
54+
5055 /**
5156 * @param string $sText
5257 * @param int $iLineNo
@@ -121,7 +126,18 @@ public function parseIdentifier($bIgnoreCase = true)
121126 }
122127 $ sCharacter = null ;
123128 while (($ sCharacter = $ this ->parseCharacter (true )) !== null ) {
124- if (preg_match ('/[a-zA-Z0-9\x{00A0}-\x{FFFF}_-]/Sux ' , $ sCharacter )) {
129+ $ escapeFree = false ;
130+
131+ if (!isset ($ this ->identifierEscapeFreeCache [$ sCharacter ])) {
132+ $ escapeFree = (strpos ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_ ' , $ sCharacter ) !== false )
133+ || (preg_match ('/[\x{00A0}-\x{FFFF}]/Sux ' , $ sCharacter ));
134+
135+ $ this ->identifierEscapeFreeCache [$ sCharacter ] = $ escapeFree ;
136+ } else {
137+ $ escapeFree = $ this ->identifierEscapeFreeCache [$ sCharacter ];
138+ }
139+
140+ if ($ escapeFree ) {
125141 $ sResult .= $ sCharacter ;
126142 } else {
127143 $ sResult .= '\\' . $ sCharacter ;
You can’t perform that action at this time.
0 commit comments