[libxml-devel] << operator

Sean Chittenden sean at chittenden.org
Thu Aug 21 16:16:27 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Note if you do this:
>
> node1 = XML::Node.new('foo')
> node1 << '<bar/>'
>
> You get this:
>
> <foo>&lt;bar/&gt;</foo>
>
> Which seems fine to me.

Agreed, I'll pass on creating an XML CSS vulnerability.

> However, that doesn't really help with this issue:

Oh!  ECOFFEE

> node = XML::Node.new('foo') << XML::Node.new('bar') <<  
> XML::Node.new('baz')
>
> If << returns self, then you get:
>
> '<foo><bar/><baz/></foo>' where node points to foo
>
> If << returns the appended child, then:
>
> '<foo><bar><baz/></bar></foo>' where node points to baz.  Its the  
> pointing to baz bit I don't like.


XML::Node.new('foo') << XML::Node.new('bar') << XML::Node.new('baz')

Should produce:

<foo><bar><baz/></bar></foo>

and

XML::Node.new('foo') << XML::Node.new('bar') + XML::Node.new('baz')

should produce the XML:

<foo><bar/><baz/></foo>

XML::Node<<(arg) should return the argument being appended *ONLY IF*  
the argument is an XML::Node, else it should return the xmlNode that  
had its content modified (e.g. XML::Attributes and Strings).

That should solve this problem.  -sc

- --
Sean Chittenden
sean at chittenden.org



-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkitzRsACgkQTrydwWwuXhb/pgCfZua676fAwCJe9hW577AnF3u0
TrIAn02in72+UCysiFXfT8pdI2G4zez+
=e45q
-----END PGP SIGNATURE-----


More information about the libxml-devel mailing list