Commit 21644b2
committed
fix: encode author names in onerror fallback to prevent XSS
The onerror handlers on testimonial avatar images interpolate t.author
directly into a JavaScript string literal. Because browsers decode HTML
entities before executing event handler attributes, a single quote in an
author name (e.g. O'Malley) breaks out of the JS string and enables
arbitrary script execution.
Apply encodeURIComponent() at build time so special characters are
percent-encoded, which both prevents the string breakout and properly
URL-encodes the ui-avatars.com name parameter.
Affects index.astro (2 instances) and shoutouts.astro (1 instance).
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>1 parent 3c43195 commit 21644b2
2 files changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
0 commit comments