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

Commit cae8d8c

Browse files
committed
Merge pull request #182 from moegeler/master
Optional Autoescaping in HeadMeta ViewHelper
2 parents f94eb8a + 0a98f6c commit cae8d8c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Helper/HeadMeta.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function itemToString(stdClass $item)
243243
if (! in_array($key, $this->modifierKeys)) {
244244
continue;
245245
}
246-
$modifiersString .= $key . '="' . $this->escapeAttribute($value) . '" ';
246+
$modifiersString .= sprintf('%s="%s"', $key, $this->autoEscape ? $this->escapeAttribute($value) : $value);
247247
}
248248

249249
$modifiersString = rtrim($modifiersString);
@@ -271,8 +271,8 @@ public function itemToString(stdClass $item)
271271
$meta = sprintf(
272272
$tpl,
273273
$type,
274-
$this->escapeAttribute($item->$type),
275-
$this->escapeAttribute($item->content),
274+
$this->autoEscape ? $this->escapeAttribute($item->$type) : $item->$type,
275+
$this->autoEscape ? $this->escapeAttribute($item->content) : $item->content,
276276
$modifiersString
277277
);
278278

test/Helper/HeadMetaTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,10 @@ public function testConditionalNoIEWidthSpace()
615615
$this->assertContains('<!--[if ! IE]><!--><', $html);
616616
$this->assertContains('<!--<![endif]-->', $html);
617617
}
618+
619+
public function testTurnOffAutoEscapeDoesNotEncode()
620+
{
621+
$this->helper->setAutoEscape(false)->appendHttpEquiv('foo', 'bar=baz');
622+
$this->assertEquals('<meta http-equiv="foo" content="bar=baz" />', $this->helper->toString());
623+
}
618624
}

0 commit comments

Comments
 (0)