Skip to content

Conversation

@r7kamura
Copy link
Contributor

@r7kamura r7kamura commented Dec 7, 2025

Added detection patterns to correctly detect some of Nokogiri's aliases as well.

Code Before After
JSON.parse(response.body) bad bad
Nokogiri::HTML(response.body) good bad
Nokogiri::HTML4(response.body) good bad
Nokogiri::HTML5(response.body) good bad
Nokogiri::HTML.parse(response.body) bad bad
Nokogiri::HTML4.parse(response.body) good bad
Nokogiri::HTML5.parse(response.body) bad bad
Nokogiri::HTML::Document.parse(response.body) good bad
Nokogiri::HTML4::Document.parse(response.body) good bad
Nokogiri::HTML5::Document.parse(response.body) good bad

Note: The originally supported Nokogiri::HTML corresponds to Nokogiri::HTML4, so both HTML4 and HTML5 were originally detected. See docs about more details:


Additionally, I simplified the offense message. This was done out of concern that optimizing the message might complicate the code, given the increased scope of this implementation.

# Before
Prefer `response.parsed_body` to `Nokogiri::HTML.parse(response.body)`.

# After
Prefer `response.parsed_body`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant