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

Safe XPath $variable binding. #329

Closed
kbloom opened this issue Aug 18, 2010 · 5 comments
Closed

Safe XPath $variable binding. #329

kbloom opened this issue Aug 18, 2010 · 5 comments

Comments

@kbloom
Copy link
Contributor

kbloom commented Aug 18, 2010

Please add support for binding $variables in XPath expressions. This behavior can be used to prevent XPath injection attacks. This is similar to REXML's XPath.first( node, "//*[@id=$href]", nil, {"href"=>"linktohere"}). This is implemented in the libxml API using the xmlXPathRegisterVariable function.

@kbloom
Copy link
Contributor Author

kbloom commented Aug 18, 2010

I now have (untested) patches for Java and libxml support for this feature at http://github.com/kbloom/nokogiri. I don't know what's the best way to implement this into Node#xpath yet, and I'm still trying figure out how to build new gems with these patches on my Debian system.

@tenderlove
Copy link
Member

adding XPath bind parameter substitution. closed by d5cddbd

@kbloom
Copy link
Contributor Author

kbloom commented Oct 15, 2010

Thank you for merging this.

@flavorjones
Copy link
Member

I've tried to document this functionality in 95240c4. Shrugs.

@kbloom
Copy link
Contributor Author

kbloom commented Oct 26, 2010

The documentation looks pretty good. Life would be easier if the #xpath interface wasn't so flexible in the first place. I'd add another example that demonstrates how to use both namespaces and variables at the same time, just to make it totally clear what's happening:

node.xpath('.//foo:address[@domestic=$value]',
      {'foo' => 'http://www.example.org/'},
      {:value => 'Yes'})

This issue was closed.
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

3 participants