File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
ruby/ql/src/queries/security/cwe-020 Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 66 <overview >
77 <p >
88 Regular expressions in Ruby can use anchors to match the beginning and end of a string.
9- However, if the <code >^</code > and <code >$</code > anchors are not used,
9+ However, if the <code >^</code > and <code >$</code > anchors are used,
1010 the regular expression can match a single line of a multi-line string.
1111 </p >
1212 </overview >
2626
2727 <sample language =" ruby" >
2828def bad(input)
29- raise "Bad input" unless input =~ /[0-9]+/
29+ raise "Bad input" unless input =~ /^ [0-9]+$ /
3030
3131 # ....
3232end
3333 </sample >
3434
3535 <p >
36- The regular expression <code >[0-9]+</code > will match a single line of a multi-line string,
36+ The regular expression <code >/^ [0-9]+$/ </code > will match a single line of a multi-line string,
3737 which may not be the intended behavior.
3838 To match the entire string, the regular expression should be <code >\A[0-9]+\z</code >.
3939 </p >
You can’t perform that action at this time.
0 commit comments