-
-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2602 from sparklemotion/flavorjones-fix-reader-no…
…de-gc_backport-v1.13.x fix: XML::Reader XML::Attr garbage collection (backport to v1.13.x) --- **What problem is this PR intended to solve?** This is a proposed fix for #2598, see that issue for an extended explanation of the problem. This PR implements "option 2" from that issue's proposed solutions: - introduce a new `Reader#attribute_hash` that will return a `Hash<String ⇒ String>` (instead of an `Array<XML::Attr>`) - deprecate `Reader#attribute_nodes` with a plan to remove it entirely in a future release - re-implement `Reader#attributes` to use `#attribute_hash` (instead of `#attribute_nodes`) After this change, only applications calling `Reader#attribute_nodes` directly will be running the unsafe code. These users will see a deprecation warning and may use `#attribute_hash` as a replacement. I think it's very possible that `Reader#attribute_hash` won't meet the needs of people who are working with namespaced attributes and are using `#attribute_nodes` for this purpose. However, I'm intentionally deferring any attempt to solve that DX problem until someone who needs this functionality asks for it. **Have you included adequate test coverage?** I tried and failed to add test coverage to the suite that would reproduce the underlying GC bug. However, existing test coverage of `Reader#attributes` is sufficient for now. **Does this change affect the behavior of either the C or the Java implementations?** This PR modifies both the C and Java implementations to behave the same. Notably, the Java implementation contains a small bugfix which is that `Reader#namespaces` now returns an empty hash when there are no namespaces (it previously returned `nil`).
- Loading branch information
Showing
10 changed files
with
215 additions
and
32 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: downstream | ||
concurrency: | ||
group: "${{github.workflow}}-${{github.ref}}" | ||
cancel-in-progress: true | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 8 * * 1,3,5" # At 08:00 on Monday, Wednesday, and Friday # https://crontab.guru/#0_8_*_*_1,3,5 | ||
push: | ||
branches: | ||
- main | ||
- v*.*.x | ||
tags: | ||
- v*.*.* | ||
pull_request: | ||
types: [opened, synchronize] | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
downstream: | ||
name: downstream-${{matrix.name}} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- url: https://github.com/flavorjones/loofah | ||
name: loofah | ||
command: "bundle exec rake test" | ||
- url: https://github.com/rails/rails-html-sanitizer | ||
name: rails-html-sanitizer | ||
command: "bundle exec rake test" | ||
- url: https://github.com/rgrove/sanitize | ||
name: sanitize | ||
command: "bundle exec rake test" | ||
- url: https://github.com/ebeigarts/signer | ||
name: signer | ||
command: "bundle exec rake spec" | ||
- url: https://github.com/WinRb/Viewpoint | ||
name: viewpoint | ||
command: "bundle exec rspec spec" | ||
- url: https://github.com/rails/rails | ||
name: xmlmini | ||
command: "cd activesupport && bundle exec rake test TESTOPTS=-n/XmlMini/" | ||
- url: https://github.com/pythonicrubyist/creek | ||
name: creek | ||
command: "bundle exec rake spec" | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/sparklemotion/nokogiri-test:mri-3.1 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ports | ||
key: ports-ubuntu-${{hashFiles('dependencies.yml', 'patches/**/*.patch')}} | ||
- run: bundle install --local || bundle install | ||
- run: bundle exec rake compile | ||
- run: | | ||
git clone --depth=1 ${{matrix.url}} ${{matrix.name}} | ||
cd ${{matrix.name}} | ||
if grep nokogiri Gemfile ; then | ||
sed -i 's/\(.*nokogiri.*\)/\1, path: ".."/' Gemfile | ||
else | ||
echo "gem 'nokogiri', path: '..'" >> Gemfile | ||
fi | ||
if egrep "add_development_dependency.*\bbundler\b" *gemspec ; then | ||
sed -i 's/.*add_development_dependency.*\bbundler\b.*//' *gemspec | ||
fi | ||
bundle install --local || bundle install | ||
${{matrix.command}} |
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
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
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
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
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
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
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
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