Created
December 28, 2010 00:29
-
-
Save avernet/756736 to your computer and use it in GitHub Desktop.
How to avoid code injections when sending XQuery to eXist
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
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
xmlns:xforms="http://www.w3.org/2002/xforms" | |
xmlns:ev="http://www.w3.org/2001/xml-events" | |
xmlns:fr="http://orbeon.org/oxf/xml/form-runner" | |
xmlns:exist="http://exist.sourceforge.net/NS/exist"> | |
<xhtml:head> | |
<xhtml:title>Preventing XQuery Injections</xhtml:title> | |
<xforms:model> | |
<xforms:instance id="form"> | |
<instance> | |
<name/> | |
</instance> | |
</xforms:instance> | |
<xforms:instance id="request"> | |
<exist:query> | |
<exist:text> | |
declare namespace request="http://exist-db.org/xquery/request"; | |
concat('Hello ', request:get-parameter('name', ''), '!') | |
</exist:text> | |
</exist:query> | |
</xforms:instance> | |
<xforms:instance id="response"><exist:result/></xforms:instance> | |
<xforms:submission id="run-query" method="post" resource="/exist/rest?name={encode-for-uri(instance('form')/name)}" | |
ref="instance('request')" replace="instance" instance="response"/> | |
</xforms:model> | |
</xhtml:head> | |
<xhtml:body> | |
<xforms:input ref="name"> | |
<xforms:label>Your name</xforms:label> | |
</xforms:input> | |
<fr:button> | |
<xforms:label>Run query</xforms:label> | |
<xforms:send ev:event="DOMActivate" submission="run-query"/> | |
</fr:button> | |
<xforms:output ref="instance('response')/exist:value"/> | |
</xhtml:body> | |
</xhtml:html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment