Browse Source

Support escaped "]" in regexp literal character classes (ex: "/[\]/]/")

https://github.com/ariya/esprima/commit/c68864d6a2873679fe3ef686276130209a298866
Sebastien Ros 12 years ago
parent
commit
f2ebd10a66
1 changed files with 11 additions and 12 deletions
  1. 11 12
      Jint/Parser/JavascriptParser.cs

+ 11 - 12
Jint/Parser/JavascriptParser.cs

@@ -975,7 +975,16 @@ namespace Jint.Parser
             {
             {
                 ch = _source.CharCodeAt(_index++);
                 ch = _source.CharCodeAt(_index++);
                 str += ch.ToString();
                 str += ch.ToString();
-                if (classMarker)
+                if (ch == '\\')
+                {
+                    ch = _source.CharCodeAt(_index++);
+                    // ECMA-262 7.8.5
+                    if (IsLineTerminator(ch))
+                    {
+                        throw new Exception(Messages.UnterminatedRegExp);
+                    }
+                    str += ch.ToString();
+                } else  if (classMarker)
                 {
                 {
                     if (ch == ']')
                     if (ch == ']')
                     {
                     {
@@ -984,17 +993,7 @@ namespace Jint.Parser
                 }
                 }
                 else
                 else
                 {
                 {
-                    if (ch == '\\')
-                    {
-                        ch = _source.CharCodeAt(_index++);
-                        // ECMA-262 7.8.5
-                        if (IsLineTerminator(ch))
-                        {
-                            throw new Exception(Messages.UnterminatedRegExp);
-                        }
-                        str += ch.ToString();
-                    }
-                    else if (ch == '/')
+                    if (ch == '/')
                     {
                     {
                         terminated = true;
                         terminated = true;
                         break;
                         break;