diff --git a/HTML/Safe.php b/HTML/Safe.php index b419522..034d0cf 100644 --- a/HTML/Safe.php +++ b/HTML/Safe.php @@ -1,4 +1,5 @@ Example: *
- * $parser = new HTML_Safe;
+ * $parser = new HTML_Safe();
  * $result = $parser->parse($doc);
  * 
* @@ -320,7 +321,7 @@ protected function writeAttrs($attrs) } if ($name == 'style') { - // removes insignificant backslahes + // removes insignificant backslashes $value = str_replace("\\", '', $value); // removes CSS comments @@ -351,7 +352,7 @@ protected function writeAttrs($attrs) } } - $tempval = preg_replace_callback('/&#(\d+);?/m', function ($matches) { return chr($matches[1]); }, $value); //"' + $tempval = preg_replace_callback('/&#(\d+);?/m', function ($matches) { return chr($matches[1]); }, $value); $tempval = preg_replace_callback( '/&#x([0-9a-f]+);?/mi', function ($matches) { return chr(hexdec($matches[1])); }, @@ -566,7 +567,7 @@ public function escapeHandler(&$parser, $data) * * Example: *
-     * $safe = new HTML_Safe;
+     * $safe = new HTML_Safe();
      * $safe->setAllowTags(array('body'));
      * 
* @@ -644,7 +645,7 @@ public function parse($doc) $doc = $this->repackUTF7($doc); // Instantiate the parser - $parser = new XML_HTMLSax3; + $parser = new XML_HTMLSax3(); // Set up the parser $parser->set_object($this); @@ -669,9 +670,9 @@ public function parse($doc) * @return string Decoded document * @access private */ - function repackUTF7($str) + public function repackUTF7($str) { - return preg_replace_callback('!\+([0-9a-zA-Z/]+)\-!', array($this, 'repackUTF7Callback'), $str); + return preg_replace_callback('!\+([0-9a-zA-Z/]+)\-!', array($this, 'repackUTF7Callback'), $str); } /** @@ -681,11 +682,11 @@ function repackUTF7($str) * @return string Recoded string * @access private */ - function repackUTF7Callback($str) + public function repackUTF7Callback($str) { - $str = base64_decode($str[1]); - $str = preg_replace_callback('/^((?:\x00.)*)((?:[^\x00].)+)/', array($this, 'repackUTF7Back'), $str); - return preg_replace('/\x00(.)/', '$1', $str); + $str = base64_decode($str[1]); + $str = preg_replace_callback('/^((?:\x00.)*)((?:[^\x00].)+)/', array($this, 'repackUTF7Back'), $str); + return preg_replace('/\x00(.)/', '$1', $str); } /** @@ -695,8 +696,8 @@ function repackUTF7Callback($str) * @return string Recoded string * @access private */ - function repackUTF7Back($str) + public function repackUTF7Back($str) { - return $str[1].'+'.rtrim(base64_encode($str[2]), '=').'-'; + return $str[1].'+'.rtrim(base64_encode($str[2]), '=').'-'; } } diff --git a/tests/HTML_SafeTest.php b/tests/HTML_SafeTest.php index 084a6ee..0c7743a 100644 --- a/tests/HTML_SafeTest.php +++ b/tests/HTML_SafeTest.php @@ -1,4 +1,5 @@

my text

'; $expected = '

my text

'; - $safe = new HTML_Safe; + $safe = new HTML_Safe(); $safe->setAllowTags(array('body')); $this->assertSame($expected, $safe->parse($input)); } @@ -24,7 +25,7 @@ public function testSpecialChars() $inputTwo = '+49-52
'; $expectedTwo = '+49-52
'; - $safe = new HTML_Safe; + $safe = new HTML_Safe(); $this->assertSame($expectedOne, $safe->parse($inputOne)); $this->assertSame($expectedTwo, $safe->parse($inputTwo)); }