Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1179)

Unified Diff: runtime/vm/json_stream.cc

Issue 542363003: Don't double-escape in strings in the VM Service, and don't use \u0000 to determine the string lengt (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: build Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/json_stream.cc
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index 762124d1c26f04caebca29650c765a6645192107..b77b01f3d4e67a57bdb32bfb34a18cc07167750e 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -217,6 +217,14 @@ void JSONStream::PrintValue(const char* s) {
}
+void JSONStream::PrintValue(const char* s, intptr_t len) {
+ PrintCommaIfNeeded();
+ buffer_.AddChar('"');
+ AddEscapedUTF8String(s, len);
+ buffer_.AddChar('"');
+}
+
+
void JSONStream::PrintValueNoEscape(const char* s) {
PrintCommaIfNeeded();
buffer_.Printf("%s", s);
@@ -302,6 +310,12 @@ void JSONStream::PrintProperty(const char* name, const char* s) {
}
+void JSONStream::PrintProperty(const char* name, const char* s, intptr_t len) {
+ PrintPropertyName(name);
+ PrintValue(s, len);
+}
+
+
void JSONStream::PrintPropertyNoEscape(const char* name, const char* s) {
PrintPropertyName(name);
PrintValueNoEscape(s);
@@ -412,6 +426,14 @@ void JSONStream::AddEscapedUTF8String(const char* s) {
return;
}
intptr_t len = strlen(s);
+ AddEscapedUTF8String(s, len);
+}
+
+
+void JSONStream::AddEscapedUTF8String(const char* s, intptr_t len) {
+ if (s == NULL) {
+ return;
+ }
const uint8_t* s8 = reinterpret_cast<const uint8_t*>(s);
intptr_t i = 0;
for (; i < len; ) {
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698