зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1395507 - Re-escape annotations holding JSON strings with newlines; r=mconley
MozReview-Commit-ID: Kx4U0wovi1u --HG-- extra : rebase_source : bf1971d66070d741499784e90a60be41091ad4dc
This commit is contained in:
Родитель
d9378b1e26
Коммит
38aca4f5a9
|
@ -118,8 +118,17 @@ function processExtraFile(extraPath) {
|
|||
try {
|
||||
let decoder = new TextDecoder();
|
||||
let extraData = await OS.File.read(extraPath);
|
||||
let keyValuePairs = parseKeyValuePairs(decoder.decode(extraData));
|
||||
|
||||
return parseKeyValuePairs(decoder.decode(extraData));
|
||||
// When reading from an .extra file literal '\\n' sequences are
|
||||
// automatically unescaped to two backslashes plus a newline, so we need
|
||||
// to re-escape them into '\\n' again so that the fields holding JSON
|
||||
// strings are valid.
|
||||
[ "TelemetryEnvironment", "StackTraces" ].forEach(field => {
|
||||
keyValuePairs[field] = keyValuePairs[field].replace(/\n/g, "n");
|
||||
});
|
||||
|
||||
return keyValuePairs;
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
return {};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
E10SCohort=unsupportedChannel
|
||||
ContentSandboxLevel=2
|
||||
TelemetryEnvironment={}
|
||||
TelemetryEnvironment={"EscapedField":"EscapedData\\n\\nfoo"}
|
||||
EMCheckCompatibility=true
|
||||
ProductName=Firefox
|
||||
ContentSandboxCapabilities=119
|
||||
|
|
|
@ -90,6 +90,14 @@ add_task(async function test_addCrash() {
|
|||
Assert.ok(false, "StackTraces does not contain valid JSON.");
|
||||
}
|
||||
|
||||
try {
|
||||
let telemetryEnvironment = JSON.parse(crash.metadata.TelemetryEnvironment);
|
||||
Assert.equal(telemetryEnvironment.EscapedField, "EscapedData\n\nfoo");
|
||||
} catch (e) {
|
||||
Assert.ok(false,
|
||||
"TelemetryEnvironment contents were not properly re-escaped\n");
|
||||
}
|
||||
|
||||
await teardown();
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче