-
-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cruby): SAX and Push parser error handling in the presence of foreign handlers #2169
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code Climate has analyzed commit f9a2c4e and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (80% is the threshold). This pull request will bring the total coverage in the repository to 94.3%. View more on Code Climate. |
This was referenced Jan 6, 2021
This was referenced Mar 5, 2021
This was referenced Mar 11, 2021
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is this PR intended to solve?
When
libxml-ruby
is loaded before Nokogiri, it sets its own global libxml2 error handlers. There are a few places where Nokogiri does not defensively remove that handler or use its own handlers. Commit 771164d (shipped in v1.11.0) removed one instance of a defensive removal, and that combined with the presence oflibxml-ruby
caused some tests to fail in ActiveSupport's test suite.This changeset introduces a systemic approach to testing handlers, setting a foreign handlers before every test in the suite and asserting that it's never called. It then introduces defensive calls to
xmlSetStructuredErrorFunc
where necessary.Notably, it also introduces a new pattern of save-and-restore the previous handler in one place where we're recursively calling HTML parsers (see EncodingReader for details). This is a pattern we should extend to all other places in the code, but in the interest of time I'm not attempting that in this changeset (I'll open a new issue to track that work and backlink to this).
Have you included adequate test coverage?
Yes, a significant part of this changeset is introducing additional test coverage.
Does this change affect the behavior of either the C or the Java implementations?
This changes the behavior of the C extension only, as it relates to libxml2 behavior.