diff options
author | Alexey Ushakov <alexey.v.ushakov@gmail.com> | 2020-01-20 12:28:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-20 12:28:17 +0300 |
commit | cbc3b66de8f779220e5f300a05a13029f76a1e48 (patch) | |
tree | df32940f177a83c9ccda94b5f18391489ba1a2fe | |
parent | 265f80d1694099bc8f334db5212a6b1a959755bd (diff) | |
parent | eae31f59754514fa02bd8a9a4596647fb16b143e (diff) | |
download | jdk8u_nashorn-jb8u242-b1644.tar.gz |
Merge pull request #6 from bell-sw/update_8u242jb8u242-b1644.3jb8u242-b1644jb8u242-b1641jb8u242-b1640jb8u232-b1644.2jetbrains-master-mirror
jdk8u242 update
-rw-r--r-- | .hgtags | 9 | ||||
-rw-r--r-- | THIRD_PARTY_README | 4 | ||||
-rw-r--r-- | src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java | 2 | ||||
-rw-r--r-- | src/jdk/nashorn/internal/runtime/regexp/joni/Config.java | 1 | ||||
-rw-r--r-- | src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java | 3 | ||||
-rw-r--r-- | src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java | 1 | ||||
-rw-r--r-- | test/script/basic/JDK-8204288.js | 35 | ||||
-rw-r--r-- | test/script/basic/JDK-8204290.js | 40 |
8 files changed, 92 insertions, 3 deletions
@@ -1058,3 +1058,12 @@ d9dd9b7ce13f7b6ff0124c47106cadf5499e7554 jdk8u232-b06 9fc2e50a5c2f98fce148bbe35e43fc17395e3afc jdk8u232-b08 fba077f48da23f914f13b11718464a547215b7f6 jdk8u232-b09 fba077f48da23f914f13b11718464a547215b7f6 jdk8u232-ga +6c540cfd25937bfddc5825a243a40a6615a9dddd jdk8u242-b01 +49b31f2616534d74144a4fa8480609e70dc56c06 jdk8u242-b02 +2c0573615bbb89bd2b522d0b4619ef513d3f51dd jdk8u242-b03 +6375475624314776773afbd023fabae34054cf52 jdk8u242-b04 +735e7a309c5b0623bf25b29a0a1e7e437d56a43c jdk8u242-b05 +0735b1dcec3677634ca632683ca14911431a236a jdk8u242-b06 +1bccea33f6dbb43bf0cb74b82bd9669aba5319ab jdk8u242-b07 +0704986602a8506f41e5a4648d724be74f1e6f95 jdk8u242-b08 +0704986602a8506f41e5a4648d724be74f1e6f95 jdk8u242-ga diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README index 7dc54a05..643ea79c 100644 --- a/THIRD_PARTY_README +++ b/THIRD_PARTY_README @@ -1334,11 +1334,13 @@ SUCH DAMAGE. -------------------------------------------------------------------------------- -%% This notice is provided with respect to Joni v1.1.9, which may be +%% This notice is provided with respect to Joni v2.1.16, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- +Copyright (c) 2017 JRuby Team + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java index dbed5d18..f5fce08b 100644 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java @@ -541,7 +541,6 @@ class ByteCodeMachine extends StackMachine { sprev = s; s++; } - sprev = sbegin; // break; } private void opAnyCharMLStar() { @@ -550,7 +549,6 @@ class ByteCodeMachine extends StackMachine { sprev = s; s++; } - sprev = sbegin; // break; } private void opAnyCharStarPeekNext() { diff --git a/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java b/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java index 65900538..f9a8c602 100644 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java @@ -45,6 +45,7 @@ public interface Config { final int NREGION = 10; final int MAX_BACKREF_NUM = 1000; + final int MAX_CAPTURE_GROUP_NUM = 0x8000; final int MAX_REPEAT_NUM = 100000; final int MAX_MULTI_BYTE_RANGES_NUM = 10000; diff --git a/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java b/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java index 48f5ce0b..2e118435 100644 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java @@ -62,6 +62,9 @@ public final class ScanEnvironment { } public int addMemEntry() { + if (numMem >= Config.MAX_CAPTURE_GROUP_NUM) { + throw new InternalException(ErrorMessages.ERR_TOO_MANY_CAPTURE_GROUPS); + } if (numMem++ == 0) { memNodes = new Node[SCANENV_MEMNODES_SIZE]; } else if (numMem >= memNodes.length) { diff --git a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java index 3c835d7b..da986489 100644 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java @@ -31,6 +31,7 @@ public interface ErrorMessages { final String ERR_PARSER_BUG = "internal parser error (bug)"; final String ERR_UNDEFINED_BYTECODE = "undefined bytecode (bug)"; final String ERR_UNEXPECTED_BYTECODE = "unexpected bytecode (bug)"; + final String ERR_TOO_MANY_CAPTURE_GROUPS = "too many capture groups"; /* syntax error */ final String ERR_END_PATTERN_AT_LEFT_BRACE = "end pattern at left brace"; diff --git a/test/script/basic/JDK-8204288.js b/test/script/basic/JDK-8204288.js new file mode 100644 index 00000000..2d325782 --- /dev/null +++ b/test/script/basic/JDK-8204288.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8204288: Matching the end of a string followed by an empty greedy regex and a word boundary fails + * + * @test + * @run + */ + + +Assert.assertEquals(new RegExp("c.*\\b").exec("abc")[0], "c"); +Assert.assertEquals(new RegExp("abc.*\\b").exec("abc")[0], "abc"); +Assert.assertEquals(new RegExp("\\b.*abc.*\\b").exec("abc")[0], "abc"); + diff --git a/test/script/basic/JDK-8204290.js b/test/script/basic/JDK-8204290.js new file mode 100644 index 00000000..4f3f7cc2 --- /dev/null +++ b/test/script/basic/JDK-8204290.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8204290: Add check to limit number of capture groups + * + * @test + * @run + */ + +try { + var captureGroups = ""; + for (i=0; i < 0x8001; i++) { captureGroups += "()"; } + new RegExp(captureGroups); + fail("Expected exception"); +} catch (e) { + Assert.assertTrue(e instanceof SyntaxError); + Assert.assertEquals(e.message, "too many capture groups"); +} + |