ruby / ruby/rdoc

Broken html when crossref matches `#<` without linking `<`

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

Nobody has claimed this yet.

Dominant language
Ruby
Stars
930
Forks
465
Avg merge
3d 10h
Merged PRs (30d)
27

Description

https://docs.ruby-lang.org/en/4.0/Encoding/Converter.html#method-i-convpath

<p>In the above example, [#&lt;Encoding:ISO-8859-1&gt;,
 <encoding:utf-8&gt;] means="" a="" converter="" from="" iso-8859-1="" to="" utf-8.="" “crlf_newline”="" newline="" lf="" crlf.<="" p="">
 </encoding:utf-8&gt;]>
</p>

Second #<Encoding with a leading space is matched:

"In the above example, [#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>] means"
  .match(RDoc::CrossReference::CROSSREF_REGEXP, 2)

# => #<MatchData " #<" 1:"#<" 2:nil 3:nil 4:nil 5:"<" 6:nil>

"<" doesn't get linked by handle_regexp_CROSSREF and assigns handled as unescaped text "<" which breaks html:

https://github.com/ruby/rdoc/blob/d6422f499fb2961b91de400f48426fc6d3fa5b67/lib/rdoc/markup/formatter.rb#L113-L115

Contributor guide

Open the contributing guide

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.

Research direction

Start in lib/rdoc/markup/formatter.rb at handle_regexp_CROSSREF and compare it with RDoc::CrossReference::CROSSREF_REGEXP using the example in the issue. Verify the generated Encoding::Converter documentation no longer contains broken HTML when a cross-reference begins with a space, while the intended references still link correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.