Roll inspector_protocol to 94298cef795ec994106bdaff002c41182911b767

This includes a fix to issue 1156334.

BUG: chromium:1156334
Change-Id: I27a97436d7a1ed567077495846dc6260ca3f2340
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2580408
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71678}
This commit is contained in:
Andrey Kosyakov 2020-12-08 22:24:22 -08:00 committed by Commit Bot
parent 9a112b549b
commit 85a8d36426
5 changed files with 37 additions and 4 deletions

View File

@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0
Revision: 22455bf37cd7a1913918e626a1997cbe77f32d1a
Revision: 94298cef795ec994106bdaff002c41182911b767
License: BSD
License File: LICENSE
Security Critical: no

View File

@ -162,7 +162,7 @@ class JSONEncoder : public ParserHandler {
Emit("\\r");
} else if (ch == '\t') {
Emit("\\t");
} else if (ch >= 32 && ch <= 126) {
} else if (ch >= 32 && ch <= 127) {
Emit(ch);
} else {
Emit("\\u");
@ -193,7 +193,7 @@ class JSONEncoder : public ParserHandler {
Emit("\\r");
} else if (c == '\t') {
Emit("\\t");
} else if (c >= 32 && c <= 126) {
} else if (c >= 32 && c <= 127) {
Emit(c);
} else if (c < 32) {
Emit("\\u");
@ -287,7 +287,7 @@ class JSONEncoder : public ParserHandler {
}
// If |value| is a scalar, emit it as an int. Taken from json_writer.cc in
// Chromium.
if (value <= std::numeric_limits<int64_t>::max() &&
if (value < static_cast<double>(std::numeric_limits<int64_t>::max()) &&
value >= std::numeric_limits<int64_t>::min() &&
std::floor(value) == value) {
Emit(std::to_string(static_cast<int64_t>(value)));

View File

@ -118,6 +118,30 @@ TEST(JsonEncoder, EscapesFFFF) {
EXPECT_EQ("\"abc\\uffffd\"", out);
}
TEST(JsonEncoder, Passes0x7FString8) {
std::vector<uint8_t> chars = {'a', 0x7f, 'b'};
std::string out;
Status status;
std::unique_ptr<ParserHandler> writer = NewJSONEncoder(&out, &status);
writer->HandleString8(span<uint8_t>(chars.data(), chars.size()));
EXPECT_EQ(
"\"a\x7f"
"b\"",
out);
}
TEST(JsonEncoder, Passes0x7FString16) {
std::vector<uint16_t> chars16 = {'a', 0x7f, 'b'};
std::string out;
Status status;
std::unique_ptr<ParserHandler> writer = NewJSONEncoder(&out, &status);
writer->HandleString16(span<uint16_t>(chars16.data(), chars16.size()));
EXPECT_EQ(
"\"a\x7f"
"b\"",
out);
}
TEST(JsonEncoder, IncompleteUtf8Sequence) {
std::string out;
Status status;

View File

@ -64,6 +64,10 @@ struct ArrayTypedef<double> { typedef std::vector<double> type; };
template <>
struct ArrayTypedef<bool> { typedef std::vector<bool> type; };
template <>
struct ArrayTypedef<Binary> { typedef std::vector<Binary> type; };
} // namespace detail
template <typename T>

View File

@ -107,6 +107,11 @@ struct ProtocolTypeTraits<{{"::".join(config.protocol.namespace)}}::Binary> {
static void Serialize(const {{"::".join(config.protocol.namespace)}}::Binary& value, std::vector<uint8_t>* bytes);
};
template <>
struct {{config.crdtp.namespace}}::detail::MaybeTypedef<{{"::".join(config.protocol.namespace)}}::Binary> {
typedef ValueMaybe<{{"::".join(config.protocol.namespace)}}::Binary> type;
};
} // {{config.crdtp.namespace}}
#endif // !defined({{"_".join(config.protocol.namespace)}}_BASE_STRING_ADAPTER_H)