@@ -10,7 +10,7 @@ injection or cross-site scripting. Usually, this is done by escaping meta-charac
1010in a domain-specific way so that they are treated as normal characters.
1111</p >
1212<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
1414error-prone. Common mistakes include only replacing the first occurrence of a meta-character, or
1515backslash-escaping various meta-characters but not the backslash itself.
1616</p >
@@ -34,12 +34,12 @@ handle corner cases correctly than a custom implementation.
3434
3535<p >
3636An 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
3838that all occurrences are replaced, and remember to escape backslashes if applicable.
3939</p >
4040<p >
4141Note, 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
4343replace further instances of the string that result from earlier replacements.
4444</p >
4545<p >
@@ -62,7 +62,7 @@ doubling single quotes, and thereby escaping them:
6262<sample src =" examples/IncompleteSanitization.rb" />
6363
6464<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
6666<i >first</i > occurrence of that string.
6767</p >
6868
@@ -74,7 +74,7 @@ that automatically sanitize parameters.
7474
7575<p >
7676If 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:
7878</p >
7979
8080<sample src =" examples/IncompleteSanitizationGood.rb" />
0 commit comments