Skip to content

Commit

Permalink
e107inc#4572: e_form: No htmlspecialchars() on "other" attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Deltik committed Sep 23, 2021
1 parent 171cac8 commit 45bce2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion e107_handlers/form_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3907,7 +3907,10 @@ public function get_attributes($options, $name = '', $value = '')
//
foreach ($options as $option => $optval)
{
$optval = htmlspecialchars(trim((string) $optval), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
if ($option !== 'other')
{
$optval = htmlspecialchars(trim((string) $optval), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
}
switch ($option)
{

Expand Down
18 changes: 17 additions & 1 deletion e107_tests/tests/unit/e_formTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,22 @@ public function testGet_attributes()

$this->assertSame($expected, $actual);
}

/**
* @link https://github.com/e107inc/e107/issues/4572
*/
public function testGet_attributesOther()
{
$options = array(
'size' => '300px',
'other' => 'v-bind:class="{ active: isActive }"',
);

$actual = $this->_frm->get_attributes($options);
$expected = ' size=\'300px\' v-bind:class="{ active: isActive }"';

$this->assertSame($expected, $actual);
}
/*
public function test_format_id()
{
Expand All @@ -879,7 +895,7 @@ public function testName2id()
$expected = 'something-hello-there-and-test';

$result = $this->_frm->name2id($text);

$this->assertEquals($expected, $result);
}
/*
Expand Down

0 comments on commit 45bce2a

Please sign in to comment.