mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1199662 - Crash ping environment block is broken when any string field contains a quotation mark. Unescape INI fields properly using the library that already exists for the purpose. r=ted
This commit is contained in:
parent
e15d441eea
commit
129907d3fd
@ -16,6 +16,7 @@ Cu.import("resource://gre/modules/Timer.jsm", this);
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
||||
Cu.import("resource://services-common/utils.js", this);
|
||||
Cu.import("resource://gre/modules/TelemetryController.jsm");
|
||||
Cu.import("resource://gre/modules/KeyValueParser.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
"CrashManager",
|
||||
@ -524,11 +525,7 @@ this.CrashManager.prototype = Object.freeze({
|
||||
// fall-through
|
||||
case "crash.main.2":
|
||||
let crashID = lines[0];
|
||||
let metadata = {};
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
let [key, val] = lines[i].split("=");
|
||||
metadata[key] = val;
|
||||
}
|
||||
let metadata = parseKeyValuePairsFromLines(lines.slice(1));
|
||||
store.addCrash(this.PROCESS_TYPE_MAIN, this.CRASH_TYPE_CRASH,
|
||||
crashID, date, metadata);
|
||||
|
||||
|
@ -214,6 +214,10 @@ add_task(function* test_main_crash_event_file() {
|
||||
yield ac.promiseInit();
|
||||
let theEnvironment = TelemetryEnvironment.currentEnvironment;
|
||||
|
||||
// To test proper escaping, add data to the environment with an embedded
|
||||
// double-quote
|
||||
theEnvironment.testValue = "MyValue\"";
|
||||
|
||||
let m = yield getManager();
|
||||
yield m.createEventsFile("1", "crash.main.2", DUMMY_DATE, "id1\nk1=v1\nk2=v2\nTelemetryEnvironment=" + JSON.stringify(theEnvironment));
|
||||
let count = yield m.aggregateEventsFiles();
|
||||
|
@ -5,6 +5,7 @@
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
"parseKeyValuePairsFromLines",
|
||||
"parseKeyValuePairs",
|
||||
"parseKeyValuePairsFromFile"
|
||||
];
|
||||
@ -12,18 +13,17 @@ this.EXPORTED_SYMBOLS = [
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
this.parseKeyValuePairs = function parseKeyValuePairs(text) {
|
||||
let lines = text.split('\n');
|
||||
this.parseKeyValuePairsFromLines = function(lines) {
|
||||
let data = {};
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i] == '')
|
||||
for (let line of lines) {
|
||||
if (line == '')
|
||||
continue;
|
||||
|
||||
// can't just .split() because the value might contain = characters
|
||||
let eq = lines[i].indexOf('=');
|
||||
let eq = line.indexOf('=');
|
||||
if (eq != -1) {
|
||||
let [key, value] = [lines[i].substring(0, eq),
|
||||
lines[i].substring(eq + 1)];
|
||||
let [key, value] = [line.substring(0, eq),
|
||||
line.substring(eq + 1)];
|
||||
if (key && value)
|
||||
data[key] = value.replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
|
||||
}
|
||||
@ -31,6 +31,11 @@ this.parseKeyValuePairs = function parseKeyValuePairs(text) {
|
||||
return data;
|
||||
}
|
||||
|
||||
this.parseKeyValuePairs = function parseKeyValuePairs(text) {
|
||||
let lines = text.split('\n');
|
||||
return parseKeyValuePairsFromLines(lines);
|
||||
};
|
||||
|
||||
this.parseKeyValuePairsFromFile = function parseKeyValuePairsFromFile(file) {
|
||||
let fstream = Cc["@mozilla.org/network/file-input-stream;1"].
|
||||
createInstance(Ci.nsIFileInputStream);
|
||||
|
Loading…
Reference in New Issue
Block a user