MCPcopy Create free account
hub / github.com/sindresorhus/execa / assertNoLineBreak

Function assertNoLineBreak

lib/arguments/command-file.js:126–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124const lineBreakRegExp = /[\n\r]/;
125
126const assertNoLineBreak = value => {
127 if (lineBreakRegExp.test(value)) {
128 throw new TypeError(`The command and its arguments cannot contain a line break on Windows without a shell.\nThis would allow a command injection with \`cmd.exe\`.\nInvalid value: ${JSON.stringify(`${value}`)}`);
129 }
130};
131
132// See https://web.archive.org/web/20241220221102/https://www.robvanderwoude.com/escapechars.php
133// eslint-disable-next-line regexp/sort-character-class-elements

Callers 1

escapeWindowsCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected