@@ -10,7 +10,7 @@ injection or cross-site scripting. Usually, this is done by escaping meta-charac
10
10
in a domain-specific way so that they are treated as normal characters.
11
11
</p >
12
12
<p >
13
- However, directly using the <code >string #sub</code > method to perform escaping is notoriously
13
+ However, directly using the <code >String #sub</code > method to perform escaping is notoriously
14
14
error-prone. Common mistakes include only replacing the first occurrence of a meta-character, or
15
15
backslash-escaping various meta-characters but not the backslash itself.
16
16
</p >
@@ -34,12 +34,12 @@ handle corner cases correctly than a custom implementation.
34
34
35
35
<p >
36
36
An even safer alternative is to design the application so that sanitization is not needed.
37
- Otherwise, make sure to use <code >string #gsub</code > rather than <code >string #sub</code >, to ensure
37
+ Otherwise, make sure to use <code >String #gsub</code > rather than <code >String #sub</code >, to ensure
38
38
that all occurrences are replaced, and remember to escape backslashes if applicable.
39
39
</p >
40
40
<p >
41
41
Note, however, that this is generally <i >not</i > sufficient for replacing multi-character strings:
42
- the <code >string #gsub</code > method performs only one pass over the input string, and will not
42
+ the <code >String #gsub</code > method performs only one pass over the input string, and will not
43
43
replace further instances of the string that result from earlier replacements.
44
44
</p >
45
45
<p >
@@ -62,7 +62,7 @@ doubling single quotes, and thereby escaping them:
62
62
<sample src =" examples/IncompleteSanitization.rb" />
63
63
64
64
<p >
65
- As written, this sanitizer is ineffective: <code >string #sub</code > will replace only the
65
+ As written, this sanitizer is ineffective: <code >String #sub</code > will replace only the
66
66
<i >first</i > occurrence of that string.
67
67
</p >
68
68
@@ -74,7 +74,7 @@ that automatically sanitize parameters.
74
74
75
75
<p >
76
76
If this is not an option, <code >escape_quotes</code > should be rewritten to use the
77
- <code >string #gsub</code > method instead:
77
+ <code >String #gsub</code > method instead:
78
78
</p >
79
79
80
80
<sample src =" examples/IncompleteSanitizationGood.rb" />
0 commit comments