Commit 7b342a23 authored by bmeurer's avatar bmeurer Committed by Commit bot

[date] Properly handle timezones with non-ASCII characters.

The timezone part of the Date string representation might contain
non-ASCII characters depending on the exact platform configuration,
so we cannot safely assume that the whole date string is ASCII
encoded.

CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel
R=yangguo@chromium.org
BUG=chromium:581925
LOG=n

Review URL: https://codereview.chromium.org/1838063002

Cr-Commit-Position: refs/heads/master@{#35089}
parent d22a7ed4
......@@ -2750,7 +2750,11 @@ BUILTIN(DateConstructor) {
char buffer[128];
Vector<char> str(buffer, arraysize(buffer));
ToDateString(time_val, str, isolate->date_cache());
return *isolate->factory()->NewStringFromAsciiChecked(str.start());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
isolate->factory()->NewStringFromUtf8(CStrVector(buffer)));
return *result;
}
......@@ -3330,7 +3334,11 @@ BUILTIN(DatePrototypeToDateString) {
char buffer[128];
Vector<char> str(buffer, arraysize(buffer));
ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly);
return *isolate->factory()->NewStringFromAsciiChecked(str.start());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
isolate->factory()->NewStringFromUtf8(CStrVector(buffer)));
return *result;
}
......@@ -3370,7 +3378,11 @@ BUILTIN(DatePrototypeToString) {
char buffer[128];
Vector<char> str(buffer, arraysize(buffer));
ToDateString(date->value()->Number(), str, isolate->date_cache());
return *isolate->factory()->NewStringFromAsciiChecked(str.start());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
isolate->factory()->NewStringFromUtf8(CStrVector(buffer)));
return *result;
}
......@@ -3381,7 +3393,11 @@ BUILTIN(DatePrototypeToTimeString) {
char buffer[128];
Vector<char> str(buffer, arraysize(buffer));
ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly);
return *isolate->factory()->NewStringFromAsciiChecked(str.start());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
isolate->factory()->NewStringFromUtf8(CStrVector(buffer)));
return *result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment