Skip to content

Commit 70b673e

Browse files
committed
fix(@angular/cli): expand shell metacharacter rejection and disable requiresQuoting
1 parent 188f6d0 commit 70b673e

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/angular/cli/src/commands/add/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { VERSION } from '../../utilities/version';
3232

3333
class CommandError extends Error {}
3434

35-
export const SHELL_METACHARACTERS = /[&|;$`()]/;
35+
export const SHELL_METACHARACTERS = /[&|;$`()<>'"\n\r]/;
3636

3737
export function validateRegistry(registry: string): void {
3838
if (!URL.canParse(registry)) {

packages/angular/cli/src/commands/add/registry-validation.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ describe('registry validation', () => {
1515
expect(SHELL_METACHARACTERS.test('|')).toBe(true);
1616
expect(SHELL_METACHARACTERS.test(';')).toBe(true);
1717
expect(SHELL_METACHARACTERS.test('$')).toBe(true);
18-
expect(SHELL_METACHARACTERS.test('`')).toBe(true);
18+
expect(SHELL_METACHARACTERS.test(String.fromCharCode(96))).toBe(true);
1919
expect(SHELL_METACHARACTERS.test('(')).toBe(true);
2020
expect(SHELL_METACHARACTERS.test(')')).toBe(true);
21+
expect(SHELL_METACHARACTERS.test('<')).toBe(true);
22+
expect(SHELL_METACHARACTERS.test('>')).toBe(true);
23+
expect(SHELL_METACHARACTERS.test('"')).toBe(true);
24+
expect(SHELL_METACHARACTERS.test("'")).toBe(true);
25+
expect(SHELL_METACHARACTERS.test('\n')).toBe(true);
26+
expect(SHELL_METACHARACTERS.test('\r')).toBe(true);
2127
});
2228

2329
it('should not match safe URL characters', () => {
@@ -47,6 +53,9 @@ describe('registry validation', () => {
4753
expect(() => validateRegistry('https://example.com(cmd)')).toThrow(
4854
'Option --registry contains invalid characters.',
4955
);
56+
expect(() => validateRegistry('https://example.com?q=">whoami')).toThrow(
57+
'Option --registry contains invalid characters.',
58+
);
5059
});
5160

5261
it('should accept valid URLs', () => {

packages/angular/cli/src/package-managers/host.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export interface Host {
107107
*/
108108
export const NodeJS_HOST: Host = {
109109
stat,
110-
requiresQuoting: platform() === 'win32',
111110
mkdir,
112111
readFile: (path: string) => readFile(path, { encoding: 'utf8' }),
113112
copyFile: (src, dest) => copyFile(src, dest, constants.COPYFILE_FICLONE),

0 commit comments

Comments
 (0)