Skip to content

Commit

Permalink
Merge branch '5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Jun 21, 2021
2 parents b76e137 + bcb806b commit 168907c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/Core/Runtime/FormRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function initializeObject()
$this->initializeFormStateFromRequest();
$this->initializeCurrentPageFromRequest();

if (!$this->isFirstRequest() && $this->getRequest()->getHttpRequest()->getMethod() === 'POST') {
if (!$this->isFirstRequest()) {
$this->processSubmittedFormValues();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Finishers/EmailFinisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function executeInternal()
}
}

protected function addMessages(SwiftMailerMessage $mail, array $messages): void
protected function addMessages(SwiftMailerMessage $mail, array $messages)
{
foreach ($messages as $messageFormat => $message) {
if (count($messages) === 1) {
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Translations/no/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<body>
<trans-unit id="forms.navigation.previousPage" xml:space="preserve">
<source>Previous page</source>
<target state="needs-translation">Previous page</target></trans-unit>
<target state="translated">Forrige side</target></trans-unit>
<trans-unit id="forms.navigation.nextPage" xml:space="preserve">
<source>Next page</source>
<target state="needs-translation">Next page</target></trans-unit>
<target state="translated">Neste side</target></trans-unit>
<trans-unit id="forms.navigation.submit" xml:space="preserve">
<source>Submit</source>
<target state="translated">Send</target></trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Translations/uk/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<target state="translated">Надіслати</target></trans-unit>
<trans-unit id="forms.pages.labelTitle" xml:space="preserve">
<source>Label</source>
<target state="needs-translation">Label</target></trans-unit>
<target state="translated">Мітка</target></trans-unit>
<trans-unit id="forms.pages.valueTitle" xml:space="preserve">
<source>Value</source>
<target state="translated">Значення</target></trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Translations/zh/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<body>
<trans-unit id="forms.navigation.previousPage" xml:space="preserve">
<source>Previous page</source>
<target state="translated">前一页</target></trans-unit>
<target state="translated">上一页</target></trans-unit>
<trans-unit id="forms.navigation.nextPage" xml:space="preserve">
<source>Next page</source>
<target state="translated">下一页</target></trans-unit>
Expand Down
25 changes: 25 additions & 0 deletions Tests/Functional/SimpleFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@ public function goingForthAndBackStoresFormValuesOfSecondPageAndTriggersValidati
Assert::assertSame('', $form['--three-page-form-with-validation']['text3-1']->getValue());
}

/**
* @test
* Thanks to Anian Weber for reporting that issue!
*/
public function validationIsNotSkippedForGetRequests()
{
$this->browser->request('http://localhost/test/form/simpleform/ThreePageFormWithValidation');

// Navigate to 2nd form page
$this->gotoNextFormPage($this->browser->getForm());

$form = $this->browser->getForm();
// Change form method to "GET"
ObjectAccess::setProperty($form, 'method', 'GET', true);

// Set invalid value (field "text2-1" has an IntegerValidator assigned)
$form['--three-page-form-with-validation']['text2-1']->setValue('My Text on the second page');

// Submit form
$this->gotoNextFormPage($form);

// Expect validation errors
Assert::assertSame(' error', $this->browser->getCrawler()->filterXPath('//*[contains(@class,"error")]//input[@id="three-page-form-with-validation-text2-1"]')->attr('class'));
}

/**
* This is an edge-case which occurs if somebody makes the formState persistent, which can happen when subclassing the FormRuntime.
Expand All @@ -94,6 +118,7 @@ public function goingForthAndBackStoresFormValuesOfSecondPageAndTriggersValidati
*/
public function goingForthAndBackStoresFormValuesOfSecondPageEvenWhenSecondPageIsManuallyCalledAsGetRequest()
{
$this->markTestSkipped('This test is skipped because we no longer allow Form validators to be skipped, see https://github.com/neos/form/security/advisories/GHSA-m5vx-8chx-qvmm');
// 1. TEST SETUP: FORM STATE PREPARATION
// - go to the 2nd page of the form, and fill in text2-1.
$this->browser->request('http://localhost/test/form/simpleform/ThreePageFormWithValidation');
Expand Down

0 comments on commit 168907c

Please sign in to comment.