Download tasks/089b05e25f35f359/source/patch.diff from FuCY/php: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/089b05e25f35f359/source/patch.diff
- Command line
-
hf download hf://datasets/FuCY/php/tasks/089b05e25f35f359/source/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/089b05e25f35f359/source/patch.diff
2.45 kB
| diff --git a/composer.json b/composer.json | |
| index a59f61f3d..438e6f48b 100644 | |
| --- a/composer.json | |
| +++ b/composer.json | |
| "laminas/laminas-view": "^2.14, required for using the laminas-form view helpers" | |
| }, | |
| "config": { | |
| - "sort-packages": true | |
| + "sort-packages": true, | |
| + "allow-plugins": { | |
| + "composer/package-versions-deprecated": true, | |
| + "dealerdirect/phpcodesniffer-composer-installer": true | |
| + } | |
| }, | |
| "extra": { | |
| "laminas": { | |
| diff --git a/src/View/Helper/FormElementErrors.php b/src/View/Helper/FormElementErrors.php | |
| index 6dc63bd24..add4dd9ba 100644 | |
| --- a/src/View/Helper/FormElementErrors.php | |
| +++ b/src/View/Helper/FormElementErrors.php | |
| use function array_merge; | |
| use function array_walk_recursive; | |
| +use function count; | |
| use function implode; | |
| use function sprintf; | |
| public function render(ElementInterface $element, array $attributes = []): strin | |
| $attributes = ' ' . $attributes; | |
| } | |
| + $count = count($messages); | |
| + $escaper = $this->getEscapeHtmlHelper(); | |
| + for ($i = 0; $i < $count; $i += 1) { | |
| + $messages[$i] = $escaper($messages[$i]); | |
| + } | |
| + | |
| // Generate markup | |
| $markup = sprintf($this->getMessageOpenFormat(), $attributes); | |
| $markup .= implode($this->getMessageSeparatorString(), $messages); | |
| diff --git a/test/View/Helper/FormElementErrorsTest.php b/test/View/Helper/FormElementErrorsTest.php | |
| index 8f939deee..cbed22097 100644 | |
| --- a/test/View/Helper/FormElementErrorsTest.php | |
| +++ b/test/View/Helper/FormElementErrorsTest.php | |
| public function testCallingTheHelperToRenderInvokeCanReturnObject(): void | |
| $helper = $this->helper; | |
| $this->assertEquals($helper(), $helper); | |
| } | |
| + | |
| + public function testHtmlEscapingOfMessages(): void | |
| + { | |
| + $messages = [ | |
| + [ | |
| + '<span>First validator message</span>', | |
| + '<span>Second validator first message</span>', | |
| + '<span>Second validator second message</span>', | |
| + ], | |
| + ]; | |
| + $element = new Element('foo'); | |
| + $element->setMessages($messages); | |
| + | |
| + $markup = $this->helper->render($element); | |
| + | |
| + $this->assertStringNotContainsString('<span>', $markup); | |
| + $this->assertStringNotContainsString('</span>', $markup); | |
| + } | |
| } | |