|
9 | 9 | Sanitizing untrusted input for HTML meta-characters is an |
10 | 10 | important technique for preventing cross-site scripting attacks. But |
11 | 11 | even a sanitized input can be dangerous to use if it is modified |
12 | | - further before it is parsed as HTML. |
| 12 | + further before a browser treats it as HTML. |
13 | 13 |
|
14 | 14 | A seemingly innocent transformation that expands a |
15 | | - self-closing HTML tag from <code>>div attr="{sanitized}"/<</code> |
16 | | - to <code>>div attr="{sanitized}"></div></code> may |
| 15 | + self-closing HTML tag from <code><div attr="{sanitized}"/></code> |
| 16 | + to <code><div attr="{sanitized}"></div></code> may |
17 | 17 | in fact cause cross-site scripting vulnerabilities. |
18 | 18 |
|
19 | 19 | </p> |
|
24 | 24 | <p> |
25 | 25 |
|
26 | 26 | Use a (well-tested) sanitization library if at all |
27 | | - possible, and avoid modifying sanitized values further before parsing |
| 27 | + possible, and avoid modifying sanitized values further before treating |
28 | 28 | them as HTML. |
29 | 29 |
|
30 | 30 | </p> |
|
49 | 49 |
|
50 | 50 | While it is generally known regular expressions are |
51 | 51 | ill-suited for parsing HTML, variants of this particular transformation |
52 | | - pattern has long been considered safe. |
| 52 | + pattern have long been considered safe. |
53 | 53 |
|
54 | 54 | </p> |
55 | 55 |
|
56 | 56 | <p> |
57 | 57 |
|
58 | 58 | However, the function is not safe. As an example, consider |
59 | | - the following string which does not result in an alert when it is |
60 | | - treated as HTML: |
| 59 | + the following string which does not result in an alert when a |
| 60 | + browser treats it as HTML: |
61 | 61 |
|
62 | 62 | </p> |
63 | 63 |
|
|
66 | 66 | <p> |
67 | 67 |
|
68 | 68 | When the above function transforms the string, it becomes |
69 | | - a string that results in an alert when it is treated as HTML by a |
70 | | - modern browser: |
| 69 | + a string that results in an alert when a browser treats it as HTML. |
71 | 70 |
|
72 | 71 | </p> |
73 | 72 |
|
|
0 commit comments