Commit 337748e4 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Escape json string for download tracing

The filename and URL may contain special characters that require escaping
Or otherwise the json file won't open

BUG=850734

Change-Id: Ic4164cd0512c0ba288b6039b2b4bd8dc4f63bb0d
Reviewed-on: https://chromium-review.googlesource.com/1091391Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565467}
parent 7d3fff95
......@@ -31,6 +31,7 @@
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/guid.h"
#include "base/json/string_escape.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
......@@ -182,12 +183,15 @@ class DownloadItemActivatedData
out->append(base::StringPrintf(
"\"type\":\"%s\",", GetDownloadTypeNames(download_type_).c_str()));
out->append(base::StringPrintf("\"id\":\"%d\",", download_id_));
out->append(
base::StringPrintf("\"original_url\":\"%s\",", original_url_.c_str()));
out->append(
base::StringPrintf("\"final_url\":\"%s\",", final_url_.c_str()));
out->append(
base::StringPrintf("\"file_name\":\"%s\",", file_name_.c_str()));
out->append("\"original_url\":");
base::EscapeJSONString(original_url_, true, out);
out->append(",");
out->append("\"final_url\":");
base::EscapeJSONString(final_url_, true, out);
out->append(",");
out->append("\"file_name\":");
base::EscapeJSONString(file_name_, true, out);
out->append(",");
out->append(
base::StringPrintf("\"danger_type\":\"%s\",",
GetDownloadDangerNames(danger_type_).c_str()));
......
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