Skip to content

RequestFactory, REQUEST_URI and absolute URLs #91

@ondrej-tuhacek

Description

@ondrej-tuhacek

Recently I installed this addon to Google Chrome:

https://chrome.google.com/webstore/detail/host-switch-plus/bopepoejgapmihklfepohbilpkcdoaeo

its purpose is something like etc/hosts file with one single exception. If used, it sends HTTP requests like:

GET http://www.example.com/ HTTP/1.1

instead of

GET / HTTP/1.1

which seems to be valid according to https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

But Nette shows "no routes" and gives me 404.

Because RequestFactory.php where $_SEVER['REQUEST_URI'] is parsed cannot handle absolute URLs. I quick-fixed this simply by modifying urlFilters from:

    /** @var array */
    public $urlFilters = array(
        'path' => array('#/{2,}#' => '/'), // '%20' => ''
        'url' => array(), // '#[.,)]\z#' => ''
    );

to:

    /** @var array */
    public $urlFilters = array(
        'path' => array('#/{2,}#' => '/'), // '%20' => ''
        'url' => array('#^(http|ftp)s?://[^/]+/#' => '/'), // '#[.,)]\z#' => ''
    );

and it works, but I'm not sure if this is the best way to "fix" this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions