Bug 1968414 - [devtools] Escape carriage return character properly r=devtools-reviewers,nchevobbe a=pascalc
Differential Revision: https://phabricator.services.mozilla.com/D254323
This commit is contained in:
committed by
pchevrel@mozilla.com
parent
95aa223cd3
commit
021fdf21d9
@@ -344,7 +344,7 @@ function testEscapeStringWin() {
|
|||||||
const newLines = "line1\r\nline2\r\rline3\n\nline4";
|
const newLines = "line1\r\nline2\r\rline3\n\nline4";
|
||||||
is(
|
is(
|
||||||
CurlUtils.escapeStringWin(newLines),
|
CurlUtils.escapeStringWin(newLines),
|
||||||
'^"line1^\n\nline2\r\rline3^\n\n^\n\nline4^"',
|
'^\"line1^\n\nline2^\n\n^\n\nline3^\n\n^\n\nline4^\"',
|
||||||
"Newlines should be escaped."
|
"Newlines should be escaped."
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ function testEscapeStringWin() {
|
|||||||
const evilCommand = `query=evil\r\rcmd" /c timeout /t 3 & calc.exe\r\r`;
|
const evilCommand = `query=evil\r\rcmd" /c timeout /t 3 & calc.exe\r\r`;
|
||||||
is(
|
is(
|
||||||
CurlUtils.escapeStringWin(evilCommand),
|
CurlUtils.escapeStringWin(evilCommand),
|
||||||
'^"query=evil\r\rcmd\\" /c timeout /t 3 & calc.exe\r\r^"',
|
'^\"query=evil^\n\n^\n\ncmd\\\" /c timeout /t 3 & calc.exe^\n\n^\n\n^\"',
|
||||||
"The evil command is escaped properly"
|
"The evil command is escaped properly"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ const CurlUtils = {
|
|||||||
// Lastly we replace new lines with ^ and TWO new lines because the first
|
// Lastly we replace new lines with ^ and TWO new lines because the first
|
||||||
// new line is there to enact the escape command the second is the character
|
// new line is there to enact the escape command the second is the character
|
||||||
// to escape (in this case new line).
|
// to escape (in this case new line).
|
||||||
.replace(/\r?\n/g, "^\n\n") +
|
.replace(/\r?\n|\r/g, "^\n\n") +
|
||||||
encapsChars
|
encapsChars
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user