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

Unexpected encoding / conversion of query string #24

Open
gesinn-it-gea opened this issue Feb 6, 2023 · 5 comments
Open

Unexpected encoding / conversion of query string #24

gesinn-it-gea opened this issue Feb 6, 2023 · 5 comments

Comments

@gesinn-it-gea
Copy link

The Page Forms extension page on mediawiki.org gives the following advice:

Note that if any part of your query string — such as a page name or anything else — contains characters such as apostrophes ('), ampersands (&), or plus signs (+), you will need to URL-encode that value. For that, you can use the urlencode function from the ParserFunctions extension. The example above, for instance, would need to change to: Quote[Author]={{urlencode:{{PAGENAME}}}}.}}

Following the above advice using query string=Template[Field]={{urlencode:Test String}} leads to Test+String being displayed in the form field.

Summary:
MW 1.35.8
PF 5.5.1

  1. {{urlencode:Test String}} → Test+String
  2. {{urlencode:Test_String}} → Test_String
  3. {{urlencode:Test String&ampersand}} → Test+String&ampersand
  4. Test String → Test String
  5. Test_String → Test_String
  6. Test String&ampersand → Test String

This leaves the user with no working combination for all cases.

@krabina
Copy link

krabina commented Feb 6, 2023

There is also {{PAGENAMEE}} btw.

@krabina
Copy link

krabina commented Feb 6, 2023

What about {{urlencode:Test String|WIKI}}?

@gesinn-it-gea
Copy link
Author

gesinn-it-gea commented Feb 6, 2023

The following commit introduced this breaking change. Before, it was working with default {{urlencode}}.

wikimedia@d29c9f3#diff-31f9c3daecfcc90f5f898ed2e119979d92c59785d26dbac658845c2199067bbc

$queryString = str_replace( '+', '%2B', $queryString ); // prevent decoding + to space character

This change is related to #autoedit Modifying a list of values

@gesinn-it-gea
Copy link
Author

7) {{urlencode:Test String|PATH}} → Test String
8) {{urlencode:Test_String|PATH}} → Test_String
9) {{urlencode:Test String&ampersand|PATH}} → Test String&ampersand
10) {{urlencode:Test String+plus|PATH}} → Test String+plus

Using option PATH seems to work. This option is not MW default and requires users to modify existing query strings.

Conclusion: this was a breaking change not marked as such.

@gesinn-it-gea gesinn-it-gea changed the title Enexpected encoding / conversion of query string Unexpected encoding / conversion of query string Feb 6, 2023
@gesinn-it-gea
Copy link
Author

A comparison between the different encodings can be found here: https://www.mediawiki.org/wiki/Manual:PAGENAMEE_encoding#Encodings_compared

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

2 participants