Skip to content

CliRouter - Presenter tries to canonize the URL and redirect #217

Open

Description

@genesiscz

Version: 3.0.0

Not sure if I missed something, but after update to 3.0.0 my cron scripts stopped working. I got them bound to Live:cron presenter for example. Running them with php /var/www/www/index.php Live:cron --do=cron --type=cloudTasks

The response is

<h1>Redirect</h1>

<p><a href="http:/live/cron?do=cron&amp;type=cloudTasks">Please click here to continue</a>.</p>

Steps To Reproduce

In my RouterFactory I use

		$router = new RouteList();
		$router[] = new \Nette\Application\Routers\CliRouter();

now run the project with the example command above and see the result.

Expected Behavior

Not autoCanonicalize the CLI requests

Possible Solution

$autoCanonicalize to false as a temporary solution.

Activity

  1. genesiscz commented on Apr 22, 2019

    @genesiscz
    Author

    Currently I used startup() for it

    	function startup() {
    		$this->autoCanonicalize = false;
    		return parent::startup(); 
    	}
    
    

    even with it, it still does try to redirect to another page

    <h1>Redirect</h1>
    
    <p><a href="http:/live/cron">Please click here to continue</a>.</p>
    

    I see that the callstack to redirectUrl is

    
    Stack trace:
    #0 /data/x/vendor/nette/application/src/Application/UI/Presenter.php(714): Tracy\Debugger::errorHandler(8, 'Undefined varia...', '/data/speeder.p...', 714, Array)
    #1 /data/x/vendor/nette/application/src/Application/UI/Component.php(297): Nette\Application\UI\Presenter->redirectUrl('http:/live/cron', NULL)
    #2 /data/x/vendor/nette/application/src/Application/UI/Presenter.php(384): Nette\Application\UI\Component->redirect(NULL)
    #3 /data/x/vendor/nette/application/src/Application/UI/Component.php(113): Nette\Application\UI\Presenter->detectedCsrf()
    #4 /data/x/vendor/nette/application/src/Application/UI/Presenter.php(368): Nette\Application\UI\Component->checkRequirements(Object(Nette\Application\UI\MethodReflection))
    #5 /data/x/vendor/nette/application/src/Application/UI/Component.php(88): Nette\Application\UI\Presenter->checkRequirements(Object(Nette\Application\UI\MethodReflection))
    #6 /data/x/vendor/nette/application/src/Application/UI/Component.php(212): Nette\Application\UI\Component->tryCall('handlecron', Array)
    #7 /data/x/vendor/nette/application/src/Application/UI/Presenter.php(408): Nette\Application\UI\Component->signalReceived('cron')
    #8 /data/x/vendor/nette/application/src/Application/UI/Presenter.php(278): Nette\Application\UI\Presenter->processSignal()
    #9 /data/x/vendor/nette/application/src/Application/Application.php(150): Nette\Application\UI\Presenter->run(Object(Nette\Application\Request))
    #10 /data/x/vendor/nette/application/src/Application/Application.php(85): Nette\Application\Application->processRequest(Object(Nette\Application\Request))
    #11 /data/x/www/index.php(35): Nette\Application\Application->run()
    #12 {main}
    

    so it's actually not just autoCanonize, but also detectedCsrf which redirect to "this"

    How was this "fixed"

    simply adding

    /**
       * @crossOrigin
       */
    

    to handleCron "fixed" the problem, but it's a bug that needs a fix, probably in checkRequirements in Nette\Application\UI\Component

  2. genesiscz commented on May 14, 2020

    @genesiscz
    Author

    Fixed in new version (not sure which version fixed this)

  3. genesiscz commented on May 14, 2020

    @genesiscz
    Author

    Ah, I forgot to delete the $this->autoCanonicalize = false;

    Still getting this in v3.0.5

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