Skip to content
Browse files

* PHPunit tests has been fixed, should be add more tests.

* Code standards



git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Safe/trunk@290181 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 9b6853e commit 9746f209a92c04a2cf989dad4b87c20410bd4794 Miguel Vazquez Gocobachi committed Nov 3, 2009
Showing with 50 additions and 77 deletions.
  1. +17 −24 docs/examples/HTML_Safe_example.php
  2. +17 −25 package.xml
  3. 0 {tests → test}/HTML_SafeTest.php
  4. +16 −0 test/testHTML_Safe.php
  5. +0 −28 tests/AllTests.php
View
41 docs/examples/HTML_Safe_example.php
@@ -1,12 +1,6 @@
<?php
error_reporting(E_ALL);
-/*
-
- Example for Safehtml
-
-*/
-
-define('XML_HTMLSAX3', dirname(__FILE__)."/classes/");
+define('XML_HTMLSAX3', dirname(__FILE__). '/classes/');
?>
<html>
<head>
@@ -41,33 +35,32 @@
<input type="submit">
</form>
<?php
-require_once('classes/safehtml.php');
+require_once 'HTML/Safe.php';
-function getmicrotime(){
- list($usec, $sec) = explode(" ",microtime());
- return ((float)$usec + (float)$sec);
+function getmicrotime()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float) $usec + (float) $sec);
}
-
-if (isset($_POST["html"]))
-{
- $doc=$_POST["html"];
+if (isset($_POST['html'])) {
+ $doc = $_POST['html'];
// Instantiate the handler
- $safehtml =& new safehtml();
+ $safehtml = new HTML_Safe();
- echo ('<pre>');
+ echo '<pre>';
// Time HTMLSax
$start = getmicrotime();
$result = $safehtml->parse($doc);
- echo ( "Parsing took seconds:\t\t".(getmicrotime()-$start) );
- echo ('</pre>');
+ echo "Parsing took seconds:\t\t" . (getmicrotime() - $start);
+ echo '</pre>';
- echo ('<b>Source code after filtration:</b><br/>');
- echo ( htmlspecialchars($result) );
+ echo '<b>Source code after filtration:</b><br/>';
+ echo htmlspecialchars($result);
- echo ('<p><b>Code after filtration as is (HTML):</b><br/>');
- echo ( $result );
+ echo '<p><b>Code after filtration as is (HTML):</b><br/>';
+ echo $result;
}
?>
<hr>
@@ -85,7 +78,7 @@ function getmicrotime(){
<li> Christian Stocker
<li> Nick Cleaton
</ul>
-<hr /> <a href="http://pixel-apes.com/safehtml">Download Safehtml</a>.
+<hr /> <a href="http://pear.php.net/packages/HTML_Safe">Download HTML_Safe</a>.
<br /> Copyright &copy; 2004-2005, Roman Ivanov.
<br /> All rights reserved.
View
42 package.xml
@@ -5,32 +5,25 @@
<summary>This parser strips down all potentially dangerous content within HTML</summary>
<description>This parser strips down all potentially dangerous content within HTML</description>
<lead>
- <name>Roman Ivanov</name>
- <user>thingol</user>
- <email>thingol@mail.ru</email>
- <active>no</active>
+ <name>Miguel Vazquez Gocobachi</name>
+ <user>demrit</user>
+ <email>demrit@php.net</email>
+ <active>yes</active>
</lead>
- <lead>
- <name>Evgeny Stepanischev</name>
- <user>bolk</user>
- <email>bolk@lixil.ru</email>
- <active>no</active>
- </lead>
- <date>2009-08-11</date>
- <time>00:59:30</time>
+ <date>2009-10-25</date>
+ <time>00:00:00</time>
<version>
- <release>0.9.9beta</release>
- <api>0.9.9beta</api>
+ <release>0.1.0beta</release>
+ <api>0.1.0beta</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license>BSD (3 Clause)</license>
<notes>
-* Added &apos;dl&apos; to the list of &apos;lists&apos; tags.
-* Added &apos;callto&apos; to the white list of protocols.
-* Added white list of &quot;namespaced&quot; attributes.
+* Support for PHP 5.0+
+* Allowed tags with setAllowTags() method.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
@@ -44,10 +37,10 @@
<dependencies>
<required>
<php>
- <min>4.1.0</min>
+ <min>5.2</min>
</php>
<pearinstaller>
- <min>1.4.0b1</min>
+ <min>1.6</min>
</pearinstaller>
<package>
<name>XML_HTMLSax3</name>
@@ -60,20 +53,19 @@
<changelog>
<release>
<version>
- <release>0.9.9beta</release>
- <api>0.9.9beta</api>
+ <release>0.1.0beta</release>
+ <api>0.1.0beta</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
- <date>2009-08-11</date>
+ <date>2009-10-25</date>
<license>BSD (3 Clause)</license>
<notes>
-* Added &apos;dl&apos; to the list of &apos;lists&apos; tags.
-* Added &apos;callto&apos; to the white list of protocols.
-* Added white list of &quot;namespaced&quot; attributes.
</notes>
+* Support for PHP 5.0+
+* Allowed tags with setAllowTags() method.
</release>
</changelog>
</package>
View
0 tests/HTML_SafeTest.php → test/HTML_SafeTest.php
File renamed without changes.
View
16 test/testHTML_Safe.php
@@ -0,0 +1,16 @@
+<?php
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once 'HTML/Safe.php';
+
+class testHTML_Safe extends PHPUnit_Framework_TestCase
+{
+ public function testAllowTags()
+ {
+ $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));
+ }
+}
View
28 tests/AllTests.php
@@ -1,28 +0,0 @@
-<?php
-if (!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'HTML_Safe_AllTests::main');
-}
-
-require_once 'PHPUnit/TextUI/TestRunner.php';
-require_once 'PHPUnit/Framework/TestSuite.php';
-
-require_once 'HTML_SafeTest.php';
-
-class HTML_Safe_AllTests {
-
- public static function main() {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite( "HTML_Safe Tests");
- $suite->addTestSuite('HTML_SafeTest');
- return $suite;
- }
-
-}
-
-if (PHPUnit_MAIN_METHOD == 'HTML_Safe_AllTests::main') {
- HTML_Safe_AllTests::main();
-}
-

0 comments on commit 9746f20

Please sign in to comment.
Something went wrong with that request. Please try again.