Commit 0cfecfe
committed
fix: strip C0 chars before javascript: check; correct mustache-literal docs/tests
- Strip U+0000–U+001F (C0 controls) from the start of the trimmed href
value before applying the javascript: check. The WHATWG URL parser
removes these characters before scheme detection, so \x00javascript:
resolves to the javascript: scheme even though String.prototype.trim()
leaves them in place.
- Fix invalid test syntax: href="{{"#"}}"` used double-quotes inside the
surrounding attribute quotes, making it unparseable template syntax.
Changed to single-quoted mustache: href="{{'#'}}".
- Correct the peer-parity audit comment that said mustache-wrapped string
literals were "dynamic and skipped" — getStaticAttrValue unwraps them,
so they ARE validated.
- Update docs to clarify only truly dynamic mustaches (PathExpressions,
helpers, dynamic concat parts) are skipped; static literal mustaches
(string/number/boolean) are validated.1 parent 45fc64b commit 0cfecfe
4 files changed
Lines changed: 7 additions & 7 deletions
File tree
- docs/rules
- lib/rules
- tests
- audit/anchor-is-valid-href-only
- lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
0 commit comments