nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.

Home Page:https://doc.nette.org/forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Infinite loop in Container::getValue()

milo opened this issue · comments

Version: 3.1.4

Bug Description

After upgrade an older application, application falls into infinite loop (and max execution time exeed error) when submitting a form with own rule which call getValues().

Steps To Reproduce

<?php

require __DIR__ . '/vendor/autoload.php';

$form = new Nette\Forms\Form;

$form
	->addText('a')
	->setRequired()
	->addRule(function () use ($form) {
		$values = $form->getValues();  # <-- recursion in validation loop
		return true;
	}, 'Invalid');

$form->addSubmit('send');

echo $form;

if ($form->isSuccess()) {
	echo '<xmp>' . print_r($form->getValues(), true) . '</xmp>';
}

Expected Behavior

Probably, throw an exception that cannot call getValues() during validation process?

The getUnsafeValues() should be used and I used it, but it took some time to discover the loop.

Thank you!