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

urlencoding issue with non-ASCII chars in request-uri header #614

Conversation

DeveloperMarius
Copy link
Contributor

Hello,

this is the fix for the issue #613.

The issue

The problem was that the route /κκκκ was not accessible. After some debugging, I found out that the complete url was urlencoded and then compared to the url of the route.
/%CE%BA%CE%BA%CE%BA%CE%BA is not /κκκκ.
When you urldecode /%CE%BA%CE%BA%CE%BA%CE%BA you get /\xce\xba\xce\xba\xce\xba\xce\xba/ (UTF-8) which is equals to /κκκκ.

So why is the url urlencoded?

A Stackoverflow post brought to my attention that the browser urlencodes special chars and passes them using the request-uri header.

The solution

I changed
$this->setUrl(new Url($this->getFirstHeader(['unencoded-url', 'request-uri'])));
to

$url = $this->getHeader('unencoded-url');
        if($url !== null){
            $this->setUrl(new Url($url));
        }else{
            $this->setUrl(new Url(urldecode($this->getHeader('request-uri'))));
        }

so that the header will now be correctly urldecoded.

~ Marius

@skipperbent
Copy link
Owner

Nice work

@skipperbent skipperbent changed the base branch from master to v4-development February 9, 2023 01:28
@skipperbent skipperbent merged commit b82e29c into skipperbent:v4-development Feb 9, 2023
@skipperbent
Copy link
Owner

@DeveloperMarius How do I make you a maintainer, can't figure it out

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.

2 participants