Skip to content

Use getHeader('unencoded_url') for IIS instead of $this->getHeader('request-uri') #268

@jatubio

Description

@jatubio

Hi simon,

I'm using IIS and i'm not sure if this issue happens also on Apache and another Web Servers.

When i have one url with utf8 characters, like: http://www.misite.com/especialidad/Dermatolog%C3%ADa or http://www.misite.com/especialidad/Dermatología, i'm getting a strangely encoded version of Dermatología, but not Dermatología or Dermatolog%C3%ADa

Strangely, for something like http://www.misite.com/?especialidad=Dermatolog%C3%ADa or http://www.misite.com/?especialidad=Dermatología i get Dermatología or Dermatolog%C3%ADa for $_GET['especialidad']

I've researched and, apparently, IIS encodes somehow the part that corresponds to the path of the url, but not on querystring part.

You can get more information here: tjanczuk/iisnode#486 and here: https://forums.iis.net/t/1153679.aspx

Then, i have made this change on __construct() method of Peece\Http\Request class:
$this->uri = urldecode($this->getHeader('unencoded_url')) ?: $this->getHeader('request-uri');

And it's working like a charm.

unencoded_url seems to be present only when url contains utf8 characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions