-
Notifications
You must be signed in to change notification settings - Fork 117
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
fix for embedded json in wps request #560
Conversation
A wps execute request with embedded json looks like this: <wps100:Execute
xmlns:wps100="http://www.opengis.net/wps/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
service="WPS"
version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
<ows110:Identifier xmlns:ows110="http://www.opengis.net/ows/1.1">orchestrate</ows110:Identifier>
<wps100:DataInputs>
<wps100:Input>
<ows110:Identifier xmlns:ows110="http://www.opengis.net/ows/1.1">workflow</ows110:Identifier>
<wps100:Data>
<wps100:ComplexData encoding="utf-8" mimeType="application/json">{"inputs": {"tas": ["CMIP6.ScenarioMIP.MIROC.MIROC6.ssp119.r1i1p1f1.day.tas.gn.v20191016"]}, "steps": {"subset_tas_1": {"run": "subset", "in": {"collection": "inputs/tas", "time": "2016-01-01/2016-03-31"}}}, "outputs": {"output": "subset_tas_1/output"}, "doc": "workflow"}</wps100:ComplexData>
</wps100:Data>
</wps100:Input>
</wps100:DataInputs>
<wps100:ResponseForm>
<wps100:ResponseDocument storeExecuteResponse="true" status="true" lineage="false">
<wps100:Output asReference="true">
<ows110:Identifier xmlns:ows110="http://www.opengis.net/ows/1.1">output</ows110:Identifier>
</wps100:Output>
<wps100:Output asReference="true">
<ows110:Identifier xmlns:ows110="http://www.opengis.net/ows/1.1">prov</ows110:Identifier>
</wps100:Output><wps100:Output asReference="true">
<ows110:Identifier xmlns:ows110="http://www.opengis.net/ows/1.1">prov_plot</ows110:Identifier>
</wps100:Output>
</wps100:ResponseDocument>
</wps100:ResponseForm>
</wps100:Execute> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the json content includes xml characters (<>) ?
Good point @huard ; can/should we CDATA the content? |
Wait, I got confused, this is already the inside of the CDATA content, correct ? Is there really something to do in OWSLib? I'm using JSON ComplexInputs in production for a while and everything works fine (using the birdy client). |
Not sure, I don't see CDATA in the example in #560 (comment) |
Yes, I think there was no |
I would need a quick fix for now ... and make it better later. |
The code is very tricky here: Lines 576 to 586 in 20e1e25
When the base64 decoding fails then it would return the original data. That is why sometimes our json input parameter worked and sometimes not ... depending on the characters. ping @agstephens |
@tomkralidis @huard I'm merging this PR as a quick-fix. Needs to be done right later (#562) |
Hello, As I said in my comment here, in my opinion the proper fix is to not decode string as base64 when the attribute encoding is not base64. The json embedded data must be properly escaped, using CDATA or XML entities when needed. The etree.parser will remove them properly. Moreover the encoding of such embedded json has to be the same as the XML as far I understand XML. As side note, json standard does not specify any encoding, it is defined as Unicode code point, thus any encoding of Unicode is a valid choice. In that regards the other option to send json is by specifying charset in the mime type as follow: |
After a double check even more in WPS 1.0.0, it seems that there is not base64 references, only the WPS 2.0.0 has base64 reference. |
Overview
This PR is a quick fix to parse an embedded json (complex type) from the wps execute request (xml).
Probably there is more work to do for embedding json in OWSLib and PyWPS. Using
CDATA
or always use base64 encoding?Related Issue / Discussion
Additional Information
Contribution Agreement
(as per https://github.com/geopython/pywps/blob/master/CONTRIBUTING.rst#contributions-and-licensing)