提交 e4b3dd28 编写于 作者: S sundar

8015353: Date.parse illegal string parsing issues

Reviewed-by: jlaskey, lagergren
上级 a6ae96e8
......@@ -39,6 +39,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.SpecializedConstructor;
import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.parser.DateParser;
import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ScriptEnvironment;
......
......@@ -23,7 +23,7 @@
* questions.
*/
package jdk.nashorn.internal.objects;
package jdk.nashorn.internal.parser;
import static java.lang.Character.DECIMAL_DIGIT_NUMBER;
import static java.lang.Character.LOWERCASE_LETTER;
......@@ -196,6 +196,11 @@ public class DateParser {
break;
case SIGN:
if (peek() == -1) {
// END after sign - wrong!
return false;
}
if (currentField == YEAR) {
yearSign = numValue;
} else if (currentField < SECOND || !setTimezone(readTimeZoneOffset(), true)) {
......@@ -297,6 +302,11 @@ public class DateParser {
break;
case SIGN:
if (peek() == -1) {
// END after sign - wrong!
return false;
}
if (!setTimezone(readTimeZoneOffset(), true)) {
return false;
}
......
/*
* Copyright (c) 2010, 2013, 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-8015353: Date.parse illegal string parsing issues
*
* @test
* @run
*/
function checkDate(str) {
if (! isNaN(Date.parse(str))) {
fail(str + " is parsed as legal Date");
}
}
checkDate("2012-01-10T00:00:00.000-");
checkDate("2012-01-01T00:00+");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册