Verified Commit 8d61aafa authored by Hubert Boma Manilla's avatar Hubert Boma Manilla Committed by ma1
Browse files

Bug 1968414 - [devtools] Escape carriage return character properly a=pascalc

parent 728bf92f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ function testEscapeStringWin() {
  const newLines = "line1\r\nline2\r\rline3\n\nline4";
  is(
    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."
  );

@@ -365,7 +365,7 @@ function testEscapeStringWin() {
  const evilCommand = `query=evil\r\rcmd" /c timeout /t 3 & calc.exe\r\r`;
  is(
    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"
  );
}
+1 −1
Original line number Diff line number Diff line
@@ -484,7 +484,7 @@ const CurlUtils = {
        // 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
        // to escape (in this case new line).
        .replace(/\r?\n/g, "^\n\n") +
        .replace(/\r?\n|\r/g, "^\n\n") +
      encapsChars
    );
  },