Commit 7ddb9c10 authored by Jérome Perrin's avatar Jérome Perrin

downloadable: Always set content-disposition: inline when displaying inline

A previous operation might have poluted the request
parent 0b6e324a
...@@ -62,9 +62,14 @@ if skin_name and skin_name != \'None\': # make_query serializes None as \'None\' ...@@ -62,9 +62,14 @@ if skin_name and skin_name != \'None\': # make_query serializes None as \'None\'
with portal.Localizer.translationContext(localizer_language):\n with portal.Localizer.translationContext(localizer_language):\n
report_data = getattr(context, deferred_style_dialog_method)(**params)\n report_data = getattr(context, deferred_style_dialog_method)(**params)\n
\n \n
attachment_name = [x[len(\' filename=\'):] for x in (request.RESPONSE.getHeader(\n attachment_name_list = [x[len(\' filename=\'):] for x in (request.RESPONSE.getHeader(\n
\'content-disposition\') or \'\').split(\';\')\n \'content-disposition\') or \'\').split(\';\')\n
if x.startswith(\' filename=\')][0]\n if x.startswith(\' filename=\')]\n
if attachment_name_list:\n
attachment_name, = attachment_name_list\n
else:\n
assert \'inline\' in (request.RESPONSE.getHeader(\'content-disposition\') or \'\')\n
attachment_name = \'index.html\'\n
if attachment_name.startswith(\'"\'):\n if attachment_name.startswith(\'"\'):\n
attachment_name = attachment_name[1:]\n attachment_name = attachment_name[1:]\n
if attachment_name.endswith(\'"\'):\n if attachment_name.endswith(\'"\'):\n
......
...@@ -82,9 +82,14 @@ with portal.Localizer.translationContext(localizer_language):\n ...@@ -82,9 +82,14 @@ with portal.Localizer.translationContext(localizer_language):\n
report_method=dummyReportMethod,\n report_method=dummyReportMethod,\n
form=portal.restrictedTraverse(form_path)))\n form=portal.restrictedTraverse(form_path)))\n
\n \n
attachment_name = [x[len(\' filename=\'):] for x in (request.RESPONSE.getHeader(\n attachment_name_list = [x[len(\' filename=\'):] for x in (request.RESPONSE.getHeader(\n
\'content-disposition\') or \'\').split(\';\')\n \'content-disposition\') or \'\').split(\';\')\n
if x.startswith(\' filename=\')][0]\n if x.startswith(\' filename=\')]\n
if attachment_name_list:\n
attachment_name, = attachment_name_list\n
else:\n
assert \'inline\' in (request.RESPONSE.getHeader(\'content-disposition\') or \'\')\n
attachment_name = \'index.html\'\n
if attachment_name.startswith(\'"\'):\n if attachment_name.startswith(\'"\'):\n
attachment_name = attachment_name[1:]\n attachment_name = attachment_name[1:]\n
if attachment_name.endswith(\'"\'):\n if attachment_name.endswith(\'"\'):\n
......
...@@ -127,6 +127,8 @@ class DownloadableMixin: ...@@ -127,6 +127,8 @@ class DownloadableMixin:
RESPONSE.setHeader('Content-Disposition', RESPONSE.setHeader('Content-Disposition',
'attachment; filename="%s"' % filename) 'attachment; filename="%s"' % filename)
RESPONSE.setHeader('Accept-Ranges', 'bytes') RESPONSE.setHeader('Accept-Ranges', 'bytes')
else:
RESPONSE.setHeader('Content-Disposition', 'inline')
return str(data) return str(data)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment