Skip to content
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

Passing a Nokogiri::XML::NodeSet to #apply_to Segfaults #452

Closed
gunn opened this issue May 3, 2011 · 2 comments
Closed

Passing a Nokogiri::XML::NodeSet to #apply_to Segfaults #452

gunn opened this issue May 3, 2011 · 2 comments

Comments

@gunn
Copy link

gunn commented May 3, 2011

This ruby:

require "nokogiri"

xsl = Nokogiri::XSLT('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"></xsl:stylesheet>')
xsl.apply_to(Nokogiri::HTML("").css("body"))

This result:

/Users/arthur/.rvm/gems/ruby-1.9.2-p0/gems/nokogiri-1.4.4/lib/nokogiri/xslt/stylesheet.rb:21: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]

-- control frame ----------
c:0005 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :transform
c:0004 p:0020 s:0014 b:0013 l:000012 d:000012 METHOD /Users/arthur/.rvm/gems/ruby-1.9.2-p0/gems/nokogiri-1.4.4/lib/nokogiri/xslt/stylesheet.rb:21
c:0003 p:0067 s:0008 b:0007 l:001598 d:001130 EVAL   untitled:4
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001598 d:001598 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
untitled:4:in `<main>'
/Users/arthur/.rvm/gems/ruby-1.9.2-p0/gems/nokogiri-1.4.4/lib/nokogiri/xslt/stylesheet.rb:21:in `apply_to'
/Users/arthur/.rvm/gems/ruby-1.9.2-p0/gems/nokogiri-1.4.4/lib/nokogiri/xslt/stylesheet.rb:21:in `transform'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Tested on ruby 1.9.2 with both nokokiri 1.4.4 and 1.5.0.beta.4

@flavorjones
Copy link
Member

I hesitate to even ask, but what would do you expect the result to be? Application to the serialized form of the nodeset?

@gunn
Copy link
Author

gunn commented May 4, 2011

@flavorjones: well to not segfault for a start. Even if no one should ever want to do this, the segfault may point to a bigger underlying bug.

What I was trying to do was to get a subset of my html (stuff within the body tag) styled nicely.
To go from:

"<div><p>one</p><p>two</p></div>"

to:

"<div>
  <p>one</p>
  <p>two</p>
</div>"

nathanl pushed a commit to nathanl/nokogiri that referenced this issue May 17, 2011
flavorjones added a commit that referenced this issue May 23, 2011
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

No branches or pull requests

2 participants