test/script/basic/JDK-8204290.js

Fri, 08 Jun 2018 11:11:06 +0200

author
hannesw
date
Fri, 08 Jun 2018 11:11:06 +0200
changeset 2522
51635f054bcb
permissions
-rw-r--r--

8204290: Add check to limit number of capture groups
Reviewed-by: sundar, jlaskey

hannesw@2522 1 /*
hannesw@2522 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
hannesw@2522 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@2522 4 *
hannesw@2522 5 * This code is free software; you can redistribute it and/or modify it
hannesw@2522 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@2522 7 * published by the Free Software Foundation.
hannesw@2522 8 *
hannesw@2522 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@2522 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@2522 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@2522 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@2522 13 * accompanied this code).
hannesw@2522 14 *
hannesw@2522 15 * You should have received a copy of the GNU General Public License version
hannesw@2522 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@2522 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@2522 18 *
hannesw@2522 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@2522 20 * or visit www.oracle.com if you need additional information or have any
hannesw@2522 21 * questions.
hannesw@2522 22 */
hannesw@2522 23
hannesw@2522 24 /**
hannesw@2522 25 * JDK-8204290: Add check to limit number of capture groups
hannesw@2522 26 *
hannesw@2522 27 * @test
hannesw@2522 28 * @run
hannesw@2522 29 */
hannesw@2522 30
hannesw@2522 31 try {
hannesw@2522 32 var captureGroups = "";
hannesw@2522 33 for (i=0; i < 0x8001; i++) { captureGroups += "()"; }
hannesw@2522 34 new RegExp(captureGroups);
hannesw@2522 35 fail("Expected exception");
hannesw@2522 36 } catch (e) {
hannesw@2522 37 Assert.assertTrue(e instanceof SyntaxError);
hannesw@2522 38 Assert.assertEquals(e.message, "too many capture groups");
hannesw@2522 39 }
hannesw@2522 40

mercurial