Skip to content

Commit

Permalink
Do not set the full url from the request as action with form parameters
Browse files Browse the repository at this point in the history
Setting an url with parameters named like form elements in a form with
method POST causes Zend to ignore any POST data because GET will be
processed with higher priority.

fixes #6806
  • Loading branch information
Johannes Meyer committed Aug 13, 2014
1 parent e7da9c0 commit 7311ab9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
8 changes: 4 additions & 4 deletions library/Icinga/Web/Form.php
Expand Up @@ -7,7 +7,6 @@
use LogicException;
use Zend_Form;
use Zend_View_Interface;
use Icinga\Application\Icinga;
use Icinga\Web\Form\Decorator\HelpText;
use Icinga\Web\Form\Decorator\ElementWrapper;
use Icinga\Web\Form\Element\CsrfCounterMeasure;
Expand Down Expand Up @@ -131,14 +130,15 @@ public function getTokenElementName()
public function create(array $formData = array())
{
if (false === $this->created) {
$this->addElements($this->createElements($formData));
$this->addCsrfCounterMeasure()->addSubmitButton();

if ($this->getAction() === '') {
// We MUST set an action as JS gets confused otherwise, if
// this form is being displayed in an additional column
$this->setAction(Icinga::app()->getFrontController()->getRequest()->getRequestUri());
$this->setAction(Url::fromRequest()->getUrlWithout(array_keys($this->getElements())));
}

$this->addElements($this->createElements($formData));
$this->addCsrfCounterMeasure()->addSubmitButton();
$this->created = true;
}

Expand Down
1 change: 0 additions & 1 deletion library/Icinga/Web/Widget/SortBox.php
Expand Up @@ -132,7 +132,6 @@ public function render()
$sort = $form->getElement('sort')->setDecorators(array('ViewHelper'));
$dir = $form->getElement('dir')->setDecorators(array('ViewHelper'));
if ($this->request) {
$form->setAction($this->request->getRequestUri());
$form->populate($this->request->getParams());
}
return $form;
Expand Down
Expand Up @@ -97,7 +97,6 @@ public function render()
);

if ($this->request) {
$form->setAction($this->request->getRequestUri());
$form->populate($this->request->getParams());
}

Expand Down

0 comments on commit 7311ab9

Please sign in to comment.