Yarr::Parser::tryConsumeGroupName() should check for the end of the pattern.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Sep 2017 23:58:33 +0000 (23:58 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Sep 2017 23:58:33 +0000 (23:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177423
<rdar://problem/34621320>

Reviewed by Keith Miller.

JSTests:

* stress/regress-177423.js: Added.

Source/JavaScriptCore:

* yarr/YarrParser.h:
(JSC::Yarr::Parser::tryConsumeGroupName):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222586 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
JSTests/stress/regress-177423.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/yarr/YarrParser.h

index c62fedb..acf1f38 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-27  Mark Lam  <mark.lam@apple.com>
+
+        Yarr::Parser::tryConsumeGroupName() should check for the end of the pattern.
+        https://bugs.webkit.org/show_bug.cgi?id=177423
+        <rdar://problem/34621320>
+
+        Reviewed by Keith Miller.
+
+        * stress/regress-177423.js: Added.
+
 2017-09-27  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Add Above/Below comparisons for UInt32 patterns
diff --git a/JSTests/stress/regress-177423.js b/JSTests/stress/regress-177423.js
new file mode 100644 (file)
index 0000000..c353338
--- /dev/null
@@ -0,0 +1 @@
+/\k</
index 0601fa4..1572d7a 100644 (file)
@@ -1,3 +1,14 @@
+2017-09-27  Mark Lam  <mark.lam@apple.com>
+
+        Yarr::Parser::tryConsumeGroupName() should check for the end of the pattern.
+        https://bugs.webkit.org/show_bug.cgi?id=177423
+        <rdar://problem/34621320>
+
+        Reviewed by Keith Miller.
+
+        * yarr/YarrParser.h:
+        (JSC::Yarr::Parser::tryConsumeGroupName):
+
 2017-09-27  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Unreviewed, fix x86 breaking due to exhausted registers
index f5afd90..378609d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009, 2014-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -999,22 +999,19 @@ private:
     std::optional<String> tryConsumeGroupName()
     {
         ParseState state = saveState();
+        StringBuilder identifierBuilder;
 
-        int ch = tryConsumeIdentifierCharacter();
-
-        if (isIdentifierStart(ch)) {
-            StringBuilder identifierBuilder;
-
-            do {
-                identifierBuilder.append(ch);
-                ch = tryConsumeIdentifierCharacter();
-                if (ch == '>') {
+        while (!atEndOfPattern()) {
+            int ch = tryConsumeIdentifierCharacter();
+            if (ch == '>') {
+                if (identifierBuilder.length())
                     return std::optional<String>(identifierBuilder.toString());
-                    break;
-                }
-                if (!isIdentifierPart(ch))
-                    break;
-            } while (!atEndOfPattern());
+                break;
+            }
+            if (!isIdentifierPart(ch))
+                break;
+
+            identifierBuilder.append(ch);
         }
 
         restoreState(state);