Skip to content

Commit

Permalink
8282134: Certain regex can cause a JS trap in WebView
Browse files Browse the repository at this point in the history
Reviewed-by: kcr, arapte
  • Loading branch information
jaybhaskar authored and kevinrushforth committed Feb 22, 2022
1 parent 418d343 commit 7396396
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ class YarrGenerator final : public YarrJITInfo, private MacroAssembler {

if (!nonGreedyFailuresDecrementIndex.empty()) {
nonGreedyFailuresDecrementIndex.link(this);
breakpoint();
sub32(TrustedImm32(1), index);
}
nonGreedyFailures.link(this);
sub32(countRegister, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,12 @@ public void onError() {
throw new AssertionError(ex);
}
}

// JDK-8282134 Certain regex can cause a JS trap in WebView
@Test public void jsRegexpTrapTest() {
final String FILE = "src/test/resources/test/html/unicode.html";
load(new File(FILE));
WebEngine web = getEngine();
assertTrue("Load task completed successfully", getLoadState() == SUCCEEDED);
}
}
13 changes: 13 additions & 0 deletions modules/javafx.web/src/test/resources/test/html/unicode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<body>
<script>
let a = "\ud800\ud800\udc00"
let b = /(.*[^x]+?)[^]*([1])/u
b.exec(a)
</script>

<p id="regtest">PASS</p>

</body>
</html>

1 comment on commit 7396396

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.