Regexp generated from unescaped input in #expand_class

Open
#1,845 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@jaynetics is already working on this.

Since Oct 10, 2026.

  • #1846 by @jaynetics — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
cli

Research direction

The unescaped input is interpolated into a regexp in #expand_class in lib/rdoc/ri/driver.rb, near line 972, and #expand_name (around line 998) calls it. Other regexps in that file escape their input, so compare with those. Pull request #1846 is already open against this issue, so review it before starting. Done means $\ no longer triggers the 'has ']' without escape' warning in tab completion, and the input is escaped the same way as elsewhere in driver.rb.

Written by the indexing model from the issue text.

Description

It happens here:

https://github.com/ruby/rdoc/blob/929a03646a2df1057570e8ab070e1f2016da5505/lib/rdoc/ri/driver.rb#L972

For example, when typing $ into IRB and then hitting tab to go through the autocomplete suggestions, this prints the following warning once $\ is reached.

rdoc/ri/driver.rb:972: warning: regular expression has ']' without escape: /\A$\[^:]*\z/
Image

Backtrace:

rdoc-8.1.0/lib/rdoc/ri/driver.rb:998:in 'RDoc::RI::Driver#expand_name'
irb-1.18.0/lib/irb/input-method.rb:410:in 'IRB::RelineInputMethod#rdoc_dialog_contents'
irb-1.18.0/lib/irb/input-method.rb:378:in 'block in IRB::RelineInputMethod#show_doc_dialog_proc'

This happens because $\ is embedded unescaped into the regexp, generating /\A$\[...].../.

Perhaps a crafty actor could even inject a Regexp that times out or raises a RegexpError.

All other regexps generated in driver.rb use escaped input, so I assume it is just an oversight in this case.

Dominant language
Ruby
Stars
930
Forks
472
Avg merge
2d 8h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/rdoc

All issues in ruby/rdoc

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.