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

Fix decoding of embedded complex data #562

Open
8 tasks
cehbrecht opened this issue Dec 16, 2020 · 2 comments
Open
8 tasks

Fix decoding of embedded complex data #562

cehbrecht opened this issue Dec 16, 2020 · 2 comments
Labels

Comments

@cehbrecht
Copy link
Collaborator

Description

The current implementation assumes that complex input data embedded in the WPS post request is base64 encoded. This is not always the case. Probably this issue needs to fixed in both OWSLib.wps and PyWPS.

See discussion in PR #560

Environment

  • operating system:
  • Python version:
  • PyWPS version: 4.2.9
  • source/distribution
  • git clone
  • Debian
  • PyPI
  • zip/tar.gz
  • other (please specify):
  • web server
  • Apache/mod_wsgi
  • CGI
  • other (please specify):

Steps to Reproduce

Additional Information

@gschwind
Copy link
Collaborator

Hello,

As far as I understand the standard WPS 1.0.0 is quite ill-formed, and the embedded data should be decoded as base64 only if the encoding attribute is base64.

Other encoding string does not make sense for PyWPS because the encoding of the XML data is the encoding used for the full XML document including text section. Note that etree.parse cleanup properly the escape sequence such as XML entities and CDATA pattern. Thus in my opinion the data should be the decoded string from etree with no more guesses, leaving the WPS implementation dealing with unknown encoding.

--- a/pywps/app/WPSRequest.py
+++ b/pywps/app/WPSRequest.py
@@ -775,7 +775,7 @@ def _get_rawvalue_value(data, encoding=None):
             return data
         elif encoding == 'base64':
             return base64.b64decode(data)
-        return base64.b64decode(data)
+        return data
     except Exception:
         LOGGER.warning("failed to decode base64")
         return data

@gschwind
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants