Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ea555e

Browse filesBrowse files
targosdanielleadams
authored andcommitted
deps: V8: cherry-pick 2ada52cffbff
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Jungshik Shin <jshin@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: #45171 PR-URL: #45573 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 6d8c0f0 commit 6ea555e
Copy full SHA for 6ea555e

File tree

Expand file treeCollapse file tree

4 files changed

+52
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+52
-3
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.12',
39+
'v8_embedder_string': '-node.13',
4040

4141
##### V8 defaults for Node.js #####
4242

Collapse file

‎deps/v8/src/date/dateparser-inl.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/date/dateparser-inl.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ DateParser::DateToken DateParser::DateStringTokenizer<CharType>::Scan() {
192192
if (in_->Skip('+')) return DateToken::Symbol('+');
193193
if (in_->Skip('.')) return DateToken::Symbol('.');
194194
if (in_->Skip(')')) return DateToken::Symbol(')');
195-
if (in_->IsAsciiAlphaOrAbove()) {
195+
if (in_->IsAsciiAlphaOrAbove() && !in_->IsWhiteSpaceChar()) {
196196
DCHECK_EQ(KeywordTable::kPrefixLength, 3);
197197
uint32_t buffer[3] = {0, 0, 0};
198198
int length = in_->ReadWord(buffer, 3);
Collapse file

‎deps/v8/src/date/dateparser.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/date/dateparser.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class DateParser : public AllStatic {
9191
// Return word length.
9292
int ReadWord(uint32_t* prefix, int prefix_size) {
9393
int len;
94-
for (len = 0; IsAsciiAlphaOrAbove(); Next(), len++) {
94+
for (len = 0; IsAsciiAlphaOrAbove() && !IsWhiteSpaceChar();
95+
Next(), len++) {
9596
if (len < prefix_size) prefix[len] = AsciiAlphaToLower(ch_);
9697
}
9798
for (int i = len; i < prefix_size; i++) prefix[i] = 0;
@@ -115,6 +116,7 @@ class DateParser : public AllStatic {
115116
bool IsEnd() const { return ch_ == 0; }
116117
bool IsAsciiDigit() const { return IsDecimalDigit(ch_); }
117118
bool IsAsciiAlphaOrAbove() const { return ch_ >= 'A'; }
119+
bool IsWhiteSpaceChar() const { return IsWhiteSpace(ch_); }
118120
bool IsAsciiSign() const { return ch_ == '+' || ch_ == '-'; }
119121

120122
// Return 1 for '+' and -1 for '-'.
Collapse file

‎deps/v8/test/intl/regress-13494.js‎

Copy file name to clipboard
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2022 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Test the new Date( date.toLocaleString("en-US")) is not invalid.
6+
// This is not guaranteed by the standard but many code use that to set the
7+
// timezone as suggested in
8+
// https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone
9+
10+
let d = new Date();
11+
12+
// https://tc39.es/ecma262/#sec-todatestring
13+
// 21.4.4.41.4 ToDateString ( tv )
14+
// 1. If tv is NaN, return "Invalid Date".
15+
let invalid = "Invalid Date";
16+
let largestDiff = 25*60*60*1000;
17+
18+
let garbage = new Date("garbage");
19+
assertTrue(invalid == garbage);
20+
assertEquals(NaN, garbage.getTime());
21+
22+
let d1 = new Date(d.toLocaleString("en-US"));
23+
assertTrue(d1 != invalid);
24+
assertTrue(d1.getTime() != NaN);
25+
// The milliseconds are different between d1 and d.
26+
assertTrue(Math.abs(d1-d) < 1000);
27+
28+
// Force a version of date string which have U+202f before AM
29+
let nnbsp_am = new Date("11/16/2022, 9:04:55\u202fAM");
30+
assertTrue(nnbsp_am != invalid);
31+
assertTrue(nnbsp_am.getTime() != NaN);
32+
// Force a version of date string which have U+202f before PM
33+
let nnbsp_pm = new Date("11/16/2022, 9:04:55\u202fPM");
34+
assertTrue(nnbsp_pm != invalid);
35+
assertTrue(nnbsp_pm.getTime() != NaN);
36+
37+
let d2 = new Date(d.toLocaleString("en-US", {timeZone: "Asia/Taipei"}));
38+
assertTrue(d2 != invalid);
39+
assertTrue(d2.getTime() != NaN);
40+
// The differences should be within 25 hours.
41+
assertTrue(Math.abs(d2-d) < largestDiff);
42+
43+
let d3 = new Date(d.toLocaleString("en-US", {timeZone: "Africa/Lusaka"}));
44+
assertTrue(d3 != invalid);
45+
assertTrue(d3.getTime() != NaN);
46+
// The differences should be within 25 hours.
47+
assertTrue(Math.abs(d3-d) < largestDiff);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.