Bill Harding
unread,Nov 16, 2010, 5:05:34 PM11/16/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nokogiri-talk
Feeling like a bit of a newb not being able to figure this one out
(and well, I guess I am a bit of a newb on Nokogiri) but here goes:
I have an Nokogiri::XML::Node that has attributes, one of which I'm
trying to remove.
I am trying to use the following code to do so:
node.attributes["background"].remove
It actually works on a few of my servers, but it does not work on my
64bit Ubuntu Lynx install. I've tried it with various versions of
Nokogiri, including 1.4.4.
Looking over the difference between my local install and the servers
that work, it appears that, on the servers,
node.attributes returns a hash, whereas on my install, node.attributes
returns a Nokogiri::XML::Element. Here's some representative HTML of
what I'm trying to parse:
<table><tr><td background="java\0script:alert('XSS')>;"></td></tr></
table>
Anyone have an idea what might cause node.attributes to not return a
hash? I notice that in NodeExtensions there is an #attributes method
that returns self. It seems that that is the behavior I'm observing.
But I don't know why my node would be defaulting to that method rather
than the method defined by Nokogiri::XML::Node.