Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Request #16510

 * adds the stub of an allowTags() method.

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Safe/trunk@287069 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit faac76117fba736506d696b28643ebb99396b8dd 1 parent a75a39f
@CloCkWeRX CloCkWeRX authored
Showing with 34 additions and 0 deletions.
  1. +21 −0 HTML/Safe.php
  2. +13 −0 tests/HTML_SafeTest.php
View
21 HTML/Safe.php
@@ -552,6 +552,27 @@ function _escapeHandler(&$parser, $data)
{
return true;
}
+ /**
+ * Allow tags
+ *
+ * Example:
+ * <pre>
+ * $safe = new HTML_Safe;
+ * $safe->setAllowTags(array('body'));
+ * </pre>
+ *
+ * @param array $tags Tags to allow
+ *
+ * @return void
+ */
+ public function setAllowTags($tags = array())
+ {
+ if (is_array($tags)) {
+ $this->_allowTags = $tags;
+ }
+ }
+
+
/**
* Returns the XHTML document
View
13 tests/HTML_SafeTest.php
@@ -1,7 +1,11 @@
<?php
require_once 'PHPUnit/Framework/TestCase.php';
+require_once 'HTML/Safe.php';
+
class HTML_SafeTest extends PHPUnit_Framework_TestCase {
+
+
public function testShouldParseCorrectly() {
$this->markTestIncomplete("Implement test coverage of parse() under a number of scenarios");
/*
@@ -20,4 +24,13 @@ function repackUTF7Back($str)
function repackUTF7Callback($str)
*/
}
+
+ public function testShouldRespectAllowTags() {
+ $input = '<html><body><p>my text</p></body></html>';
+ $expected = '<body><p>my text</p></body>';
+
+ $safe = new HTML_Safe();
+ $safe->setAllowTags(array('body'));
+ $this->assertSame($expected, $safe->parse($input));
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.