From d57b2e889c23c83dd96d3ca9ace1d9fe7cb7db6e Mon Sep 17 00:00:00 2001 From: filip1 Date: Tue, 10 Mar 2020 15:40:43 +0100 Subject: [PATCH] fix truncated query strings in ref URLs When the widget is embedded on a URL containing a query string such as https://example.com/path?foo=1&bar=2, the widget[ref] parameter that gets sent on form submission and saved as "ref" in the database is truncated before the first "=" character. That means it gets stored as https://example.com/path?foo I think that wrapping the URL string in encodeURIComponent() before appending it to the serialized form should fix the issue. --- web/js/policat_widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/policat_widget.js b/web/js/policat_widget.js index 2f4bdf5..ae23ccb 100644 --- a/web/js/policat_widget.js +++ b/web/js/policat_widget.js @@ -1104,7 +1104,7 @@ $(document).ready(function($) { refName = 'widget[ref]'; break; } - $.post(window.location.href.split('#', 1)[0], form.serialize() + '&' + refName + '=' + ref, function(data) { + $.post(window.location.href.split('#', 1)[0], form.serialize() + '&' + refName + '=' + encodeURIComponent(ref), function(data) { switch (formId) { case 'sign': window.parent.postMessage('policat_signed;' + JSON.stringify({iframe: iframe_no, widget: widget_id}) , '*');