From 879eb6ee9f6ce1add170b78104e60ba32549fc18 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 20 Mar 2018 12:27:56 +0100 Subject: [PATCH] Widget: fix broken iframe detection --- src/pretix/presale/forms/checkout.py | 2 +- src/pretix/static/pretixpresale/js/widget/widget.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py index 4b3f034100..a597b8fce6 100644 --- a/src/pretix/presale/forms/checkout.py +++ b/src/pretix/presale/forms/checkout.py @@ -39,7 +39,7 @@ class ContactForm(forms.Form): help_text=_('Please enter the same email address again to make sure you typed it correctly.') ) - if self.request.session.get('iframe_session', False): + if not self.request.session.get('iframe_session', False): # There is a browser quirk in Chrome that leads to incorrect initial scrolling in iframes if there # is an autofocus field. Who would have thought… See e.g. here: # https://floatboxjs.com/forum/topic.php?post=8440&usebb_sid=2e116486a9ec6b7070e045aea8cded5b#post8440 diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index 39a93ca8f8..5aa31d7ac4 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -406,7 +406,12 @@ var shared_methods = { if (data.redirect.substr(0, 1) === '/') { data.redirect = this.$root.event_url.replace(/^([^\/]+:\/\/[^\/]+)\/.*$/, "$1") + data.redirect; } - var url = data.redirect + '?iframe=1&locale=' + lang + '&take_cart_id=' + this.$root.cart_id; + var url = data.redirect; + if (url.indexOf('?')) { + url = url + '&iframe=1&locale=' + lang + '&take_cart_id=' + this.$root.cart_id; + } else { + url = url + '?iframe=1&locale=' + lang + '&take_cart_id=' + this.$root.cart_id; + } if (data.success === false) { url = url.replace(/checkout\/start/g, ""); this.$root.error_message = data.message;