Skip to content

Commit

Permalink
[Hardening] Make sure content is always a sring on plain content types
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jun 10, 2020
1 parent cf07a41 commit 5c01978
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions geonode/proxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io
import os
import re
import six
import gzip
import json
import shutil
Expand Down Expand Up @@ -199,6 +200,19 @@ def proxy(request, url=None, response_callback=None,
f = gzip.GzipFile(fileobj=buf)
content = f.read()

PLAIN_CONTENT_TYPES = [
'text',
'plain',
'html',
'json',
'xml',
'gml'
]
for _ct in PLAIN_CONTENT_TYPES:
if _ct in content_type and not isinstance(content, six.string_types):
content = content.decode()
break

if response and response_callback:
kwargs = {} if not kwargs else kwargs
kwargs.update({
Expand Down

0 comments on commit 5c01978

Please sign in to comment.