Skip to content

Commit

Permalink
* PHPunit tests has been fixed, should be add more tests.
Browse files Browse the repository at this point in the history
* Code standards



git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Safe/trunk@290181 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Miguel Vazquez Gocobachi committed Nov 3, 2009
1 parent 9b6853e commit 9746f20
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 77 deletions.
41 changes: 17 additions & 24 deletions docs/examples/HTML_Safe_example.php
@@ -1,12 +1,6 @@
<?php <?php
error_reporting(E_ALL); error_reporting(E_ALL);
/* define('XML_HTMLSAX3', dirname(__FILE__). '/classes/');
Example for Safehtml
*/

define('XML_HTMLSAX3', dirname(__FILE__)."/classes/");
?> ?>
<html> <html>
<head> <head>
Expand Down Expand Up @@ -41,33 +35,32 @@
<input type="submit"> <input type="submit">
</form> </form>
<?php <?php
require_once('classes/safehtml.php'); require_once 'HTML/Safe.php';


function getmicrotime(){ function getmicrotime()
list($usec, $sec) = explode(" ",microtime()); {
return ((float)$usec + (float)$sec); list($usec, $sec) = explode(" ", microtime());
return ((float) $usec + (float) $sec);
} }



if (isset($_POST['html'])) {
if (isset($_POST["html"])) $doc = $_POST['html'];
{
$doc=$_POST["html"];


// Instantiate the handler // Instantiate the handler
$safehtml =& new safehtml(); $safehtml = new HTML_Safe();


echo ('<pre>'); echo '<pre>';
// Time HTMLSax // Time HTMLSax
$start = getmicrotime(); $start = getmicrotime();
$result = $safehtml->parse($doc); $result = $safehtml->parse($doc);
echo ( "Parsing took seconds:\t\t".(getmicrotime()-$start) ); echo "Parsing took seconds:\t\t" . (getmicrotime() - $start);
echo ('</pre>'); echo '</pre>';


echo ('<b>Source code after filtration:</b><br/>'); echo '<b>Source code after filtration:</b><br/>';
echo ( htmlspecialchars($result) ); echo htmlspecialchars($result);


echo ('<p><b>Code after filtration as is (HTML):</b><br/>'); echo '<p><b>Code after filtration as is (HTML):</b><br/>';
echo ( $result ); echo $result;
} }
?> ?>
<hr> <hr>
Expand All @@ -85,7 +78,7 @@ function getmicrotime(){
<li> Christian Stocker <li> Christian Stocker
<li> Nick Cleaton <li> Nick Cleaton
</ul> </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 /> Copyright &copy; 2004-2005, Roman Ivanov.
<br /> All rights reserved. <br /> All rights reserved.


Expand Down
42 changes: 17 additions & 25 deletions package.xml
Expand Up @@ -5,32 +5,25 @@
<summary>This parser strips down all potentially dangerous content within HTML</summary> <summary>This parser strips down all potentially dangerous content within HTML</summary>
<description>This parser strips down all potentially dangerous content within HTML</description> <description>This parser strips down all potentially dangerous content within HTML</description>
<lead> <lead>
<name>Roman Ivanov</name> <name>Miguel Vazquez Gocobachi</name>
<user>thingol</user> <user>demrit</user>
<email>thingol@mail.ru</email> <email>demrit@php.net</email>
<active>no</active> <active>yes</active>
</lead> </lead>
<lead> <date>2009-10-25</date>
<name>Evgeny Stepanischev</name> <time>00:00:00</time>
<user>bolk</user>
<email>bolk@lixil.ru</email>
<active>no</active>
</lead>
<date>2009-08-11</date>
<time>00:59:30</time>
<version> <version>
<release>0.9.9beta</release> <release>0.1.0beta</release>
<api>0.9.9beta</api> <api>0.1.0beta</api>
</version> </version>
<stability> <stability>
<release>beta</release> <release>beta</release>
<api>beta</api> <api>beta</api>
</stability> </stability>
<license>BSD (3 Clause)</license> <license>BSD (3 Clause)</license>
<notes> <notes>
* Added &apos;dl&apos; to the list of &apos;lists&apos; tags. * Support for PHP 5.0+
* Added &apos;callto&apos; to the white list of protocols. * Allowed tags with setAllowTags() method.
* Added white list of &quot;namespaced&quot; attributes.
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="/" name="/"> <dir baseinstalldir="/" name="/">
Expand All @@ -44,10 +37,10 @@
<dependencies> <dependencies>
<required> <required>
<php> <php>
<min>4.1.0</min> <min>5.2</min>
</php> </php>
<pearinstaller> <pearinstaller>
<min>1.4.0b1</min> <min>1.6</min>
</pearinstaller> </pearinstaller>
<package> <package>
<name>XML_HTMLSax3</name> <name>XML_HTMLSax3</name>
Expand All @@ -60,20 +53,19 @@
<changelog> <changelog>
<release> <release>
<version> <version>
<release>0.9.9beta</release> <release>0.1.0beta</release>
<api>0.9.9beta</api> <api>0.1.0beta</api>
</version> </version>
<stability> <stability>
<release>beta</release> <release>beta</release>
<api>beta</api> <api>beta</api>
</stability> </stability>
<date>2009-08-11</date> <date>2009-10-25</date>
<license>BSD (3 Clause)</license> <license>BSD (3 Clause)</license>
<notes> <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> </notes>
* Support for PHP 5.0+
* Allowed tags with setAllowTags() method.
</release> </release>
</changelog> </changelog>
</package> </package>
File renamed without changes.
16 changes: 16 additions & 0 deletions 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));
}
}
28 changes: 0 additions & 28 deletions tests/AllTests.php

This file was deleted.

0 comments on commit 9746f20

Please sign in to comment.