Skip to content

Commit 5f48cc0

Browse files
committed
Ruby: Fix off-by-one error in getGroupName
1 parent 6dd126b commit 5f48cc0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ruby/ql/lib/codeql/ruby/security/performance/ParseRegExp.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ abstract class RegExp extends AST::StringlikeLiteral {
488488
this.group(start, end) and
489489
exists(int nameEnd |
490490
this.namedGroupStart(start, nameEnd) and
491-
result = this.getText().substring(start + 4, nameEnd - 1)
491+
result = this.getText().substring(start + 3, nameEnd - 1)
492492
)
493493
}
494494

ruby/ql/test/library-tests/regexp/regexp.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
groupName
2-
| regexp.rb:52:2:52:11 | (?<id>\\w+) | d |
3-
| regexp.rb:53:2:53:12 | (?'foo'fo+) | oo |
4-
| regexp.rb:57:2:57:11 | (?<qux>q+) | ux |
2+
| regexp.rb:52:2:52:11 | (?<id>\\w+) | id |
3+
| regexp.rb:53:2:53:12 | (?'foo'fo+) | foo |
4+
| regexp.rb:57:2:57:11 | (?<qux>q+) | qux |
55
groupNumber
66
| regexp.rb:46:2:46:6 | (foo) | 1 |
77
| regexp.rb:47:4:47:8 | (o\|b) | 1 |

0 commit comments

Comments
 (0)