Skip to content

Bug: Canonical logic accept domain.com///// #6

Closed

Description

@janbarasek
  • bug report? yes
  • feature request? yes
  • version: v3.0.0

Description

In case of domain.com//// internal method match(IRequest $httpRequest): ?array got fake URL with only one slash.

Some example (CustomRouter.php):

public function match(IRequest $httpRequest): ?array
{
	$url = $httpRequest->getUrl();
	dump($url);
	dump($url->getAbsoluteUrl());
	$realUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http')
		. '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	dump($realUrl);
	die;

In production mode dump looks like this:

Snímek obrazovky 2020-02-12 v 10 05 47

So object UrlScript contains invalid URL and I can open URL https://nette.org, https://nette.org/ and https://nette.org///// too without canonical redirect.

Steps To Reproduce

Open https://nette.org///// for example:

Snímek obrazovky 2020-02-12 v 10 08 39

Thanks.

Activity

  1. JanTvrdik commented on Feb 12, 2020

    @JanTvrdik
    Contributor

    There's a built-in path filter in Nette\Http\RequestFactory which replaces sequence of / with a single /. See https://github.com/nette/http/blob/v3.0.3/src/Http/RequestFactory.php#L28

  2. janbarasek commented on Feb 12, 2020

    @janbarasek
    Author

    Yes, of course, but I think this is a natural duplication that should be redirected.

  3. janbarasek commented on Feb 23, 2020

    @janbarasek
    Author

    @dg How can I solve this issue? This bug makes a number of duplicate pages and damages SEO.

    I think firstly I must fix Url entity which should support sequence of / in case of homepage or ending with it.

    Thanks.

  4. dg commented on Feb 6, 2021

    @dg
    Member

    This is related to nette/http, I know about it and it will be addressed in version 4.0.

  5. added 5 commits that reference this issue on Feb 8, 2021
    1e5f5f7
    aa6e464
    662646b
    ddb2490
    30b313f
  6. added 2 commits that reference this issue on Dec 12, 2021
    6f86f3d
    333b29c
  7. added 2 commits that reference this issue on Apr 16, 2022
    30e7c39
    7e8d216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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