Commit 820314a5 authored by Gabriel Monnerat's avatar Gabriel Monnerat Committed by Kirill Smelkov

erp5_web_render_js_ui: Support ? and & in the URL after login

When accessing the web site, the page is redirected to login page with came_from equal https://URL/web_site_module/WEBSITE/#!login{?n.me}

When trying to replace, nothing changes, the page is redirected to the url in came_from and we have this error:

Error: Error: Unsupported command login{
parent 75864476
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
import re\n
REQUEST = context.REQUEST\n REQUEST = context.REQUEST\n
RESPONSE = REQUEST.RESPONSE\n RESPONSE = REQUEST.RESPONSE\n
from ZTUtils import make_query\n from ZTUtils import make_query\n
...@@ -73,10 +74,13 @@ else:\n ...@@ -73,10 +74,13 @@ else:\n
# XXX Hardcoded behaviour for JS app.\n # XXX Hardcoded behaviour for JS app.\n
# Expect came_from to be an URL template\n # Expect came_from to be an URL template\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
url_parameter = "n.me"\n
pattern = \'{[&|?]%s}\' % url_parameter\n
if (person is None):\n if (person is None):\n
came_from = came_from.replace(\'{&n.me}\', \'\')\n came_from = re.sub(pattern, \'\', came_from)\n
else:\n else:\n
came_from = came_from.replace(\'{&n.me}\', \'&%s\' % make_query({\'n.me\': person.getRelativeUrl()}))\n prefix = "&" if "&%s" % url_parameter in came_from else "?"\n
came_from = re.sub(pattern, \'%s%s\' % (prefix, make_query({url_parameter: person.getRelativeUrl()})), came_from)\n
# RESPONSE.redirect(came_from or context.getPermanentURL(context));\n # RESPONSE.redirect(came_from or context.getPermanentURL(context));\n
RESPONSE.setHeader(\'Location\', came_from or context.getPermanentURL(context))\n RESPONSE.setHeader(\'Location\', came_from or context.getPermanentURL(context))\n
RESPONSE.setStatus(303)\n RESPONSE.setStatus(303)\n
......
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