Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yarnpkg/parsers

Package Overview
Dependencies
Maintainers
6
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/parsers - npm Package Compare versions

Comparing version 3.0.0-rc.48.1 to 3.0.0-rc.49

47

lib/shell.js

@@ -79,18 +79,41 @@ "use strict";

exports.stringifyValueArgument = stringifyValueArgument;
const ESCAPED_CONTROL_CHARS = new Map([
[`\f`, `\\f`],
[`\n`, `\\n`],
[`\r`, `\\r`],
[`\t`, `\\t`],
[`\v`, `\\v`],
[`\0`, `\\0`],
]);
const ESCAPED_DBL_CHARS = new Map([
[`\\`, `\\\\`],
[`$`, `\\$`],
[`"`, `\\"`],
...Array.from(ESCAPED_CONTROL_CHARS, ([c, replacement]) => {
return [c, `"$'${replacement}'"`];
}),
]);
const getEscapedControlChar = (c) => {
return ESCAPED_CONTROL_CHARS.get(c) ?? `\\x${c.charCodeAt(0).toString(16).padStart(2, `0`)}`;
};
const getEscapedDblChar = (match) => {
return ESCAPED_DBL_CHARS.get(match) ?? `"$'${getEscapedControlChar(match)}'"`;
};
function stringifyArgumentSegment(argumentSegment) {
const doubleQuoteIfRequested = (string, quote) => quote ? `"${string}"` : string;
const doubleQuoteIfRequested = (string, quote) => quote
? `"${string}"`
: string;
const quoteIfNeeded = (text) => {
if (text === ``)
return `""`;
if (!text.match(/[(){}<>$|&; \t"']/))
return `''`;
if (!text.match(/[()}<>$|&;"'\n\t ]/))
return text;
return `$'${text
.replace(/\\/g, `\\\\`)
.replace(/'/g, `\\'`)
.replace(/\f/g, `\\f`)
.replace(/\n/g, `\\n`)
.replace(/\r/g, `\\r`)
.replace(/\t/g, `\\t`)
.replace(/\v/g, `\\v`)
.replace(/\0/g, `\\0`)}'`;
if (!text.match(/['\t\p{C}]/u))
return `'${text}'`;
if (!text.match(/'/)) {
return `$'${text.replace(/[\t\p{C}]/u, getEscapedControlChar)}'`;
}
else {
return `"${text.replace(/["$\t\p{C}]/u, getEscapedDblChar)}"`;
}
};

@@ -97,0 +120,0 @@ switch (argumentSegment.type) {

{
"name": "@yarnpkg/parsers",
"version": "3.0.0-rc.48.1",
"version": "3.0.0-rc.49",
"license": "BSD-2-Clause",

@@ -43,3 +43,6 @@ "main": "./lib/index.js",

},
"engines": {
"node": ">=18.12.0"
},
"stableVersion": "2.5.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc