Created
October 6, 2011 04:04
-
-
Save freshtonic/1266497 to your computer and use it in GitHub Desktop.
Nokogiri clobbers LibXML's error handlers
This file contains hidden or 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
| describe "Nokogiri & LibXML interaction" do | |
| it "LibXML's error handler should not be clobbered by Nokogiri::XSLT(...)" do | |
| malformed_xml = '<?xml version="1.0" encoding="utf-8"?> | |
| <some_tag> | |
| </some_tag_with_typo>' | |
| xslt = '<?xml version="1.0" ?> | |
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
| <xsl:template match="product"> | |
| </xsl:template>' | |
| begin | |
| # Comment out this line and the spec passes. | |
| Nokogiri::XSLT(StringIO.new(xslt)) | |
| rescue Exception | |
| end | |
| errors = [] | |
| LibXML::XML::Error.set_handler do |foo| | |
| errors << foo | |
| end | |
| reader = LibXML::XML::Reader.io(StringIO.new(malformed_xml)) | |
| begin | |
| while reader.read | |
| end | |
| rescue | |
| end | |
| errors.size.should == 1 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment