curl.js (basilisk-2021.12.14-source.tar.xz) | : | curl.js (basilisk-2022.01.27-source.tar.xz) | ||
---|---|---|---|---|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ | /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ | |||
/* This Source Code Form is subject to the terms of the Mozilla Public | /* This Source Code Form is subject to the terms of the Mozilla Public | |||
* License, v. 2.0. If a copy of the MPL was not distributed with this | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |||
/* | /* | |||
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | |||
* Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | |||
* Copyright (C) 2011 Google Inc. All rights reserved. | * Copyright (C) 2011 Google Inc. All rights reserved. | |||
* Copyright (C) 2009 Mozilla Foundation. All rights reserved. | * Copyright (C) 2009 Mozilla Foundation. All rights reserved. | |||
* Copyright (C) 2022 Moonchild Productions. All rights reserved. | ||||
* | * | |||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | |||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | |||
* are met: | * are met: | |||
* | * | |||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | |||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | |||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | |||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | |||
* documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. | |||
skipping to change at line 403 | skipping to change at line 404 | |||
// Use single quote syntax. | // Use single quote syntax. | |||
return "'" + str + "'"; | return "'" + str + "'"; | |||
}, | }, | |||
/** | /** | |||
* Escape util function for Windows systems. | * Escape util function for Windows systems. | |||
* Credit: Google DevTools | * Credit: Google DevTools | |||
*/ | */ | |||
escapeStringWin: function (str) { | escapeStringWin: function (str) { | |||
/* | /* | |||
Replace dollar sign because of commands (e.g $(cmd.exe)) in | Replace the backtick character ` with `` in order to escape it. | |||
powershell when using double quotes. | The backtick character is an escape character in PowerShell and | |||
Useful details http://www.rlmueller.net/PowerShellEscape.htm | can, among other things, be used to disable the effect of some | |||
of the other escapes created below. | ||||
Replace dollar sign because of commands in powershell when using | ||||
double quotes. e.g $(calc.exe). | ||||
Also see http://www.rlmueller.net/PowerShellEscape.htm for details. | ||||
Replace quote by double quote (but not by \") because it is | Replace quote by double quote (but not by \") because it is | |||
recognized by both cmd.exe and MS Crt arguments parser. | recognized by both cmd.exe and MS Crt arguments parser. | |||
Replace % by "%" because it could be expanded to an environment | Replace % by "%" because it could be expanded to an environment | |||
variable value. So %% becomes "%""%". Even if an env variable "" | variable value. So %% becomes "%""%". Even if an env variable "" | |||
(2 doublequotes) is declared, the cmd.exe will not | (2 doublequotes) is declared, the cmd.exe will not | |||
substitute it with its value. | substitute it with its value. | |||
Replace each backslash with double backslash to make sure | Replace each backslash with double backslash to make sure | |||
MS Crt arguments parser won't collapse them. | MS Crt arguments parser won't collapse them. | |||
Replace new line outside of quotes since cmd.exe doesn't let | Replace new line outside of quotes since cmd.exe doesn't let | |||
to do it inside. | us do it inside. | |||
*/ | */ | |||
return "\"" + str.replace(/\$/g, "`$") | return "\"" + | |||
.replace(/"/g, "\"\"") | str.replaceAll("`", "``") | |||
.replace(/%/g, "\"%\"") | .replaceAll("$", "`$") | |||
.replace(/\\/g, "\\\\") | .replaceAll('"', '""') | |||
.replace(/[\r\n]+/g, "\"^$&\"") + "\""; | .replaceAll("%", '"%"') | |||
.replace(/\\/g, "\\\\") | ||||
.replace(/[\r\n]+/g, "\"^$&\"") + "\""; | ||||
} | } | |||
}; | }; | |||
exports.CurlUtils = CurlUtils; | exports.CurlUtils = CurlUtils; | |||
End of changes. 4 change blocks. | ||||
9 lines changed or deleted | 18 lines changed or added |