Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#5499 in develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/StripTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ protected function _filterTag($tag)
foreach ($matches[1] as $index => $attributeName) {
$attributeName = strtolower($attributeName);
$attributeDelimiter = empty($matches[2][$index]) ? $matches[4][$index] : $matches[2][$index];
$attributeValue = empty($matches[3][$index]) ? $matches[5][$index] : $matches[3][$index];
$attributeValue = (strlen($matches[3][$index]) == 0) ? $matches[5][$index] : $matches[3][$index];

// If the attribute is not allowed, then remove it entirely
if (!array_key_exists($attributeName, $this->tagsAllowed[$tagName])
Expand Down
12 changes: 12 additions & 0 deletions test/StripTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,4 +556,16 @@ public function testReturnUnfiltered($input)
{
$this->assertEquals($input, $this->_filter->filter($input));
}

/**
* @link https://github.com/zendframework/zf2/issues/5465
*/
public function testAttributeValueofZeroIsNotRemoved()
{
$input = '<div id="0" data-custom="0" class="bogus"></div>';
$expected = '<div id="0" data-custom="0"></div>';
$this->_filter->setTagsAllowed('div');
$this->_filter->setAttributesAllowed(array('id','data-custom'));
$this->assertEquals($expected, $this->_filter->filter($input));
}
}

0 comments on commit c523da1

Please sign in to comment.