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

Unified Diff: base/trace_event/trace_event_impl.cc

Issue 1870563002: Escape name and category of trace events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_event_impl.cc
diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc
index 4ab0d358f9d202dd31ba6418b098da6751348e05..3ed0f7dedb60e574587bd8768431775779626cb0 100644
--- a/base/trace_event/trace_event_impl.cc
+++ b/base/trace_event/trace_event_impl.cc
@@ -293,10 +293,12 @@ void TraceEvent::AppendAsJSON(
// Category group checked at category creation time.
DCHECK(!strchr(name_, '"'));
StringAppendF(out, "{\"pid\":%i,\"tid\":%i,\"ts\":%" PRId64
- ","
- "\"ph\":\"%c\",\"cat\":\"%s\",\"name\":\"%s\",\"args\":",
- process_id, thread_id, time_int64, phase_, category_group_name,
- name_);
+ ",\"ph\":\"%c\",\"cat\":",
+ process_id, thread_id, time_int64, phase_);
+ EscapeJSONString(category_group_name, true, out);
Primiano Tucci (use gerrit) 2016/04/07 13:30:08 In which case does a category name contain quotes?
Mario Pistrich 2016/04/07 13:50:58 Yeah, I've added it just to be sure - should I rem
Primiano Tucci (use gerrit) 2016/04/07 16:17:56 I am pretty sure that if somebody adds quotes to t
Mario Pistrich 2016/04/07 18:59:52 Okay, sounds reasonable, I removed escaping the tr
+ *out += ",\"name\":";
+ EscapeJSONString(name_, true, out);
+ *out += ",\"args\":";
// Output argument names and values, stop at first NULL argument name.
// TODO(oysteine): The dual predicates here is a bit ugly; if the filtering
« no previous file with comments | « no previous file | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698