Commit abe0167f authored by Jérome Perrin's avatar Jérome Perrin

officejs: remove duplicated WebPage_viewAsWeb

Having WebPage_viewAsWeb in default skin selection break other sites
relying on default behavior of erp5_web.
parent 0a4b94fb
Pipeline #8247 failed with stage
in 0 seconds
if REQUEST is None:
REQUEST = context.REQUEST
if response is None:
response = REQUEST.RESPONSE
# The vanilla HTML is wanted
response.setBase(None)
web_page = context
web_section = REQUEST.get("current_web_section")
#if REQUEST.getHeader('If-Modified-Since', '') == web_page.getModificationDate().rfc822():
# response.setStatus(304)
# return ""
portal_type = web_page.getPortalType()
if portal_type in ("Web Page", "Web Script", "Web Manifest", "Web Style"):
web_content = web_page.getTextContent()
else:
if portal_type == "Web Section":
web_page = web_page.getAggregateValue()
response.setHeader('Content-Type', web_page.getContentType())
web_content = web_page.getData()
# set headers depending on type of script
if (portal_type == "Web Script"):
response.setHeader('Content-Type', 'application/javascript; charset=utf-8')
elif (portal_type == "Web Style"):
response.setHeader('Content-Type', 'text/css; charset=utf-8')
elif (portal_type == "Web Manifest"):
response.setHeader('Content-Type', 'text/cache-manifest; charset=utf-8')
elif (portal_type == "Web Page"):
if (mapping_dict is not None):
web_content = web_page.TextDocument_substituteTextContent(web_content, mapping_dict=mapping_dict)
content_security_policy = "default-src 'self' data: blob: *"
x_frame_options = "SAMEORIGIN"
if (web_section):
content_security_policy = web_section.getLayoutProperty("configuration_content_security_policy", default=content_security_policy)
x_frame_options = web_section.getLayoutProperty("configuration_x_frame_options", default=x_frame_options)
# Do not allow to put inside an iframe
if not x_frame_options == "ALLOW-FROM-ALL":
response.setHeader("X-Frame-Options", x_frame_options)
response.setHeader("X-Content-Type-Options", "nosniff")
# Only fetch code (html, js, css, image) and data from this ERP5, to prevent any data leak as the web site do not control the gadget's code
response.setHeader("Content-Security-Policy", content_security_policy)
response.setHeader('Content-Type', web_page.getContentType('text/html'))
return web_content
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None, mapping_dict=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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