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

Fix interpretation of plus signs #992

Open
wants to merge 2 commits into
base: bugfix
Choose a base branch
from
Open

Conversation

pupi1985
Copy link
Contributor

@pupi1985 pupi1985 commented Mar 3, 2024

I think a part of a previous PR should be rolled back.

There are quite a few sources of information and discussion about the plus sign, which is the main difference between the urlencode and rawurlencode functions, along with their counterparts:

However, currently, when trying to search "a b" results in the page heading showing "Search results for a+b". So rethought the whole encoding issue and split the problem in two:

  1. Interpreting URLs
  2. Generating URLs

At the beginning I thought about following the standard in both cases, but now I think it doesn't make much sense.

  1. Approach when interpreting URLs: Even though I don't like it, Q2A needs to process these two URLs as the same valid URL: https://site.com/user/one+two and https://site.com/user/one%20two. The main issue here becomes forms (as shown in the links above). In short, forms will turn spaces into plus signs by default. So even if it is not following the standard, we need to process them in this way.
    Furthermore, $_GET superglobal gets their values already processed by urldecode.
  2. Approach when generating URLs: I don't think there is any need to avoid following a standard when generating URLs. For example, if there is a space in a query string such as in a user profile, it should turn into a %20, rather than a +

Turning this into concrete changes, I'd say when creating URLs, we should keep the rawurlencode function calls. When interpreting the URLs, which happens in the index.php file, we should change the current rawurldecode functions to urldecode.

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

Successfully merging this pull request may close these issues.

1 participant