Commit cb4a373
committed
fix(@schematics/angular): escape module specifier in insertImport
insertImport builds an `import ... from '<fileName>'` statement by
interpolating fileName directly between single quotes with no escaping.
A fileName containing a single quote breaks out of the string literal,
so any caller that passes untrusted data as the module specifier (e.g.
a schematic using addRootProvider's external() with a value sourced
from user/project config) ends up inserting attacker-controlled source
into the target file rather than a plain import path.
fileName is now escaped for backslashes and single quotes before being
interpolated, matching the existing single-quote output format so the
common case (a real module specifier) is byte-for-byte unchanged.1 parent 0ae5690 commit cb4a373
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
0 commit comments