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

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

Open
genesiscz opened this issue Apr 22, 2019 · 3 comments
Open

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

genesiscz opened this issue Apr 22, 2019 · 3 comments

Comments

@genesiscz
Copy link

genesiscz commented Apr 22, 2019

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.

@genesiscz
Copy link
Author

genesiscz commented Apr 22, 2019

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

@genesiscz
Copy link
Author

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

@genesiscz
Copy link
Author

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

Still getting this in v3.0.5

@genesiscz genesiscz reopened this May 14, 2020
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

No branches or pull requests

1 participant