summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-04 16:33:30 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-04 16:33:30 +0000
commit1a2e4945f16f5dff4aba518a36edf938c9234ac3 (patch)
treea8c400af9af58d365ea0bfaad45b954081005b10 /fxjs
parent3faa382d4feb3c272333f20e16106a5bbc472990 (diff)
downloadpdfium-1a2e4945f16f5dff4aba518a36edf938c9234ac3.tar.xz
Parse "yy" correctly for AFDate_FormatEx().
AFDate_FormatEx("yymmdd") should not try to read the first 4 digits in the string. BUG=chromium:436572 Change-Id: I123b70b8a22d1e2c87e61ee7bf0b177b49571ae3 Reviewed-on: https://pdfium-review.googlesource.com/29731 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cjs_publicmethods.cpp2
-rw-r--r--fxjs/cjs_publicmethods_embeddertest.cpp8
2 files changed, 9 insertions, 1 deletions
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index ea4ea713d8..375eb6fd88 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -559,7 +559,7 @@ double CJS_PublicMethods::MakeRegularDate(const WideString& value,
} else if (remaining == 1 || format[i + 2] != c) {
switch (c) {
case 'y':
- nYear = ParseStringInteger(value, j, &nSkip, 4);
+ nYear = ParseStringInteger(value, j, &nSkip, 2);
i += 2;
j += nSkip;
break;
diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp
index 90efee9078..9413aa6a46 100644
--- a/fxjs/cjs_publicmethods_embeddertest.cpp
+++ b/fxjs/cjs_publicmethods_embeddertest.cpp
@@ -99,6 +99,14 @@ TEST_F(CJS_PublicMethodsEmbedderTest, MakeRegularDate) {
date = RoundDownDate(date);
EXPECT_DOUBLE_EQ(1107216000000.0, date);
EXPECT_FALSE(bWrongFormat);
+
+ // 2005 in a different format. https://crbug.com/436572
+ bWrongFormat = false;
+ date =
+ CJS_PublicMethods::MakeRegularDate(L"050201", L"yymmdd", &bWrongFormat);
+ date = RoundDownDate(date);
+ EXPECT_DOUBLE_EQ(1107216000000.0, date);
+ EXPECT_FALSE(bWrongFormat);
}
TEST_F(CJS_PublicMethodsEmbedderTest, MakeFormatDate) {