Permalink
Browse files

Prepared 0.10.0 release

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Safe/trunk@297546 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
Miguel Vazquez Gocobachi
Miguel Vazquez Gocobachi committed Apr 5, 2010
1 parent eeecf48 commit cd6db98d726bc3efdae22b146eff5cc562fcee7d
Showing with 23 additions and 56 deletions.
  1. +5 −51 HTML/Safe.php
  2. +4 −4 package.xml
  3. +14 −1 tests/testHTML_Safe.php
View
@@ -613,6 +613,7 @@ public function clear()
*/
public function parse($doc)
{
+ $result = '';
// Save all '<' symbols
$doc = preg_replace("/<(?=[^a-zA-Z\/\!\?\%])/", '&lt;', $doc);
@@ -623,11 +624,8 @@ public function parse($doc)
// Opera6 bug workaround
$doc = str_replace("\xC0\xBC", '&lt;', $doc);
- // UTF-7 encoding ASCII decode
- $doc = $this->repackUTF7($doc);
-
// Instantiate the parser
- $parser=& new XML_HTMLSax3();
+ $parser = new XML_HTMLSax3;
// Set up the parser
$parser->set_object($this);
@@ -638,54 +636,10 @@ public function parse($doc)
$parser->parse($doc);
- return $this->getXHTML();
- }
+ $result = $this->getXHTML();
+ $this->clear();
- /**
- * UTF-7 decoding fuction
- *
- * @param string $str HTML document for recode ASCII part of UTF-7 back to ASCII
- *
- * @return string Decoded document
- */
- public function repackUTF7($str)
- {
- return preg_replace_callback(
- '!\+([0-9a-zA-Z/]+)\-!',
- array($this, 'repackUTF7Callback'),
- $str
- );
- }
-
- /**
- * Additional UTF-7 decoding fuction
- *
- * @param string $str String for recode ASCII part of UTF-7 back to ASCII
- *
- * @return string Recoded string
- */
- 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);
- }
-
- /**
- * Additional UTF-7 encoding fuction
- *
- * @param string $str String for recode ASCII part of UTF-7 back to ASCII
- *
- * @return string Recoded string
- */
- public function repackUTF7Back($str)
- {
- return $str[1] . '+' . rtrim(base64_encode($str[2]), '=') . '-';
+ return $result;
}
}
View
@@ -13,12 +13,12 @@
<date>2009-11-04</date>
<time>08:45:00</time>
<version>
- <release>0.10.0beta</release>
- <api>0.10.0beta</api>
+ <release>0.10.0</release>
+ <api>0.10.0</api>
</version>
<stability>
- <release>beta</release>
- <api>beta</api>
+ <release>release</release>
+ <api>release</api>
</stability>
<license>BSD (3 Clause)</license>
<notes>
View
@@ -9,8 +9,21 @@ public function testAllowTags()
$input = '<html><body><p>my text</p></body></html>';
$expected = '<body><p>my text</p></body>';
- $safe = new HTML_Safe();
+ $safe = new HTML_Safe;
$safe->setAllowTags(array('body'));
$this->assertSame($expected, $safe->parse($input));
}
+
+ public function testSpecialChars()
+ {
+ $inputOne = 'a+b-c';
+ $expectedOne = 'a+b-c';
+
+ $inputTwo = '+49-52 <br />';
+ $expectedTwo = '+49-52 <br />';
+
+ $safe = new HTML_Safe;
+ $this->assertSame($expectedOne, $safe->parse($inputOne));
+ $this->assertSame($expectedTwo, $safe->parse($inputTwo));
+ }
}

0 comments on commit cd6db98

Please sign in to comment.