Skip to content
Permalink
Browse files

Helpers: htmlspecialchars() strict type fix (#229)

  • Loading branch information...
milo authored and dg committed Aug 19, 2019
1 parent 9270dac commit 2ca348aa51b626acd6bbfcc3e60f5ed3a52ed6a9
Showing with 6 additions and 1 deletion.
  1. +1 −1 src/Forms/Helpers.php
  2. +5 −0 tests/Forms/Helpers.createInputList.phpt
@@ -152,7 +152,7 @@ public static function createInputList(array $items, array $inputAttrs = null, a
$res .= ($res === '' && $wrapperEnd === '' ? '' : $wrapper)
. $labelTag . $label->attributes() . '>'
. $inputTag . $input->attributes() . (Html::$xhtml ? ' />' : '>')
. ($caption instanceof Nette\Utils\IHtmlString ? $caption : htmlspecialchars($caption, ENT_NOQUOTES, 'UTF-8'))
. ($caption instanceof Nette\Utils\IHtmlString ? $caption : htmlspecialchars((string) $caption, ENT_NOQUOTES, 'UTF-8'))
. '</label>'
. $wrapperEnd;
}
@@ -25,6 +25,11 @@ test(function () {
Helpers::createInputList(['a'])
);
Assert::same(
'<label><input value="0">1</label>',
Helpers::createInputList([1])
);
Assert::same(
'<label><input value="a">First</label><label><input value="b">Second</label>',
Helpers::createInputList(

0 comments on commit 2ca348a

Please sign in to comment.
You can’t perform that action at this time.