Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect to url with query string does not encode the input from shortcode #11049

Closed
5 tasks done
ghost opened this issue Apr 3, 2020 · 8 comments
Closed
5 tasks done

Comments

@ghost
Copy link

ghost commented Apr 3, 2020

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest stable version of Elementor.

Description

I use a simple form with an input field and a button. The text input has a field id and in the redirect settings of the form I target a different site with a query string from this specific field id: "mydomain.de/kontakt?queryId=[field id="myId"]".
I noticed that the string from the field id is not encoded, producing urls like this: "mydomain.de/kontakt?queryId=just an example".

A guide from the Elementor page (https://docs.elementor.com/article/451-dynamic-request-parameter) shows in the gif at the bottom of the page a similar behaviour.
In my opinion, the query string should be encoded in order to use special characters etc.

Steps to reproduce

  • Build a form with text input and button
  • Give the text input an id and copy the shortcode with the [ ] brackets
  • Add "Redirect" to the actions after form submit
  • Specify a Redirect Url with query params like this: "mydomain.de?queryparam=your_shortcode
  • Submit the form and the that the string from the input is not encoded or otherwise escaped, special characters will cause problems

Isolating the problem

  • This bug happens with only Elementor plugin active (and Elementor Pro).
  • This bug happens with a default WordPress theme active.
  • I can reproduce this bug consistently using the steps above.

Other

If I use an unfitting way to solve my use case, I'd be happy to hear another option :)
I want a form on the landing page with user input. After the user types some words and clicks the button, he should be redirect to a form where one of the fields is filled with the users input from the landing page.
Here is my page: http://lagerbox-merzig.de/

@diecreativo
Copy link

This is a BUG.

When the URL is:

mydomain.com/?name=field id=name]

Does not redirect due to space between field and id.

@shilo-ey
Copy link
Contributor

This issue has been resolved in Elementor Pro v2.9.3

Feel free to update

Thanks!

@ghost
Copy link
Author

ghost commented Apr 20, 2020

@shilo-ey
The fix did not tackle my problem.
Fix: Form shortcode IDs are not wrapped in double-quotes (#11023, #10932, #10967, #11000, #11049)
The problem is not the shortcode IDs but the actual content which is not escaped like a URL query String. Instead it will just use the raw String in the url params which leads to problems with special characters. See the site I posted and type a special character like 'ö'

@TitoFM16
Copy link

TitoFM16 commented Dec 30, 2022

@barttermorshuizen
Copy link

Not fixed indeed. Anything passed into the query string is not encoded, causing the redirect to fail.

@barttermorshuizen
Copy link

@TitoFM16 : i've seen your workaround - where would this code go?
I'm a bit confused about your use case. wouldnt just urlencode() be sufficient to fix the issue?

@barttermorshuizen
Copy link

@shilo-ey can you reopen please? Issue is not fixed

@TitoFM16
Copy link

TitoFM16 commented Feb 15, 2023

@TitoFM16 : i've seen your workaround - where would this code go? I'm a bit confused about your use case. wouldnt just urlencode() be sufficient to fix the issue?

@barttermorshuizen This code can go whenever you want, but is easier to create this file on the root folder of your WP installation, I don't know if urlencode() is enough to fix the URL but for sure not to redirect, instead I use html_entity_decode to fix the &amp or any other Html Entity to unicode & so the code works as follow:

1- You don't do the redirect to the page you want instead you do the request to the path where the code is, for example www.yourdomain.com/custom-encoder.php

2 - then in the $request_uri = $_SERVER['REQUEST_URI']; you will get from www.yourdomain.com/custom-encoder.php/query1=data1&ampquery2=data2&ampquery3=data3 just the : custom-encoder.php/query1=data1&ampquery2=data2&ampquery3=data3 so I erase the custom-encoder.php/ and just let the query params

3- then I create the final url concatenating the url to where I want to redirect with the wrong query strings that you got on the point 2.

4- then with the html_entity_decode function I fix the final to have the correct characters and finally I redirect to the correct url with correct encoding.

I just tried with the urlencode and this does not work as you expect, I think the best approach is my workaround, if you need something else, just reply for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants