geopython/pywps

Fix decoding of embedded complex data

cehbrecht opened this issue · 2 comments

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

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

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.