|
5 | 5 |
|
6 | 6 | <overview> |
7 | 7 | <p> |
8 | | - Directly writing user input (for example, an HTTP request parameter) to a webpage |
| 8 | + Directly writing user input (for example, an HTTP request parameter) to a webpage, |
9 | 9 | without properly sanitizing the input first, allows for a cross-site scripting |
10 | 10 | vulnerability. |
11 | 11 | </p> |
|
19 | 19 | </p> |
20 | 20 |
|
21 | 21 | <p> |
22 | | - Care should be taken when using methods such as <code>html_safe</code> or |
23 | | - <code>raw</code>. These methods can be used to output a string without escaping |
24 | | - it. As such, they should only be used when the string has already been manually |
| 22 | + Take care when using methods such as <code>html_safe</code> or |
| 23 | + <code>raw</code>. They can be used to emit a string without escaping |
| 24 | + it, and should only be used when the string has already been manually |
25 | 25 | escaped (for example, with the Rails <code>html_escape</code> method), or when |
26 | 26 | the content is otherwise guaranteed to be safe (such as a hard-coded string). |
27 | 27 | </p> |
28 | 28 | </recommendation> |
29 | 29 |
|
30 | 30 | <example> |
31 | 31 | <p> |
32 | | - In the following example is safe because the |
| 32 | + The following example is safe because the |
33 | 33 | <code>params[:user_name]</code> content within the output tags will be |
34 | | - automatically HTML escaped before being output. |
| 34 | + HTML-escaped automatically before being emitted. |
35 | 35 | </p> |
36 | 36 | <sample src="examples/safe.html.erb" /> |
37 | 37 |
|
38 | 38 | <p> |
39 | 39 | However, the following example is unsafe because user-controlled input is |
40 | | - output without escaping due to being marked as <code>html_safe</code>. |
| 40 | + output without escaping, since it is marked as <code>html_safe</code>. |
41 | 41 | </p> |
42 | 42 | <sample src="examples/reflective_xss.html.erb" /> |
43 | 43 | </example> |
|
0 commit comments