Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/Zend/Form/View/Helper/AbstractHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function getDoctype()
public function setEncoding($encoding)
{
$this->getEscapeHtmlHelper()->setEncoding($encoding);
$this->getEscapeHtmlAttrHelper()->setEncoding($encoding);
return $this;
}

Expand Down
26 changes: 26 additions & 0 deletions tests/ZendTest/Form/View/Helper/AbstractHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

namespace ZendTest\Form\View\Helper;
use Zend\Escaper\Escaper;

/**
* Tests for {@see \Zend\Form\View\Helper\AbstractHelper}
Expand All @@ -33,4 +34,29 @@ public function testWillEscapeValueAttributeValuesCorrectly()
$this->helper->createAttributesString(array('data-value' => 'breaking your HTML like a boss! \\'))
);
}

public function testWillEncodeValueAttributeValuesCorrectly()
{

$string = (new Escaper('iso-8859-1'))->escapeHtmlAttr('Título');

$this->helper->setEncoding('iso-8859-1');

$this->assertSame(
'data-value="' . $string . '"',
$this->helper->createAttributesString(array('data-value' => 'Título'))
);
}

public function testWillNotEncodeValueAttributeValuesCorrectly()
{

$string = (new Escaper('iso-8859-1'))->escapeHtmlAttr('Título');

$this->assertNotSame(
'data-value="' . $string . '"',
$this->helper->createAttributesString(array('data-value' => 'Título'))
);
}

}
11 changes: 11 additions & 0 deletions tests/ZendTest/Form/View/Helper/CommonTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ public function testInjectingEncodingProxiesToEscapeHelper()
$this->assertEquals('iso-8859-1', $escape->getEncoding());
}

public function testInjectingEncodingProxiesToAttrEscapeHelper()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}

$escape = $this->renderer->plugin('escapehtmlattr');
$this->helper->setEncoding('iso-8859-1');
$this->assertEquals('iso-8859-1', $escape->getEncoding());
}

public function testAssumesHtml4LooseDoctypeByDefault()
{
if (!extension_loaded('intl')) {
Expand Down