mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
[1.7.0] Fix bug in Bool class
- Genericize allElements into basic smoketest, add beginnings of legacy smoketest too. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1113 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
f985d3cd96
commit
9c5f01a0cf
@ -15,7 +15,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
function validate($string, $config, &$context) {
|
function validate($string, $config, &$context) {
|
||||||
if (empty($string)) return false;
|
if (empty($string)) return false;
|
||||||
return $name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once 'common.php';
|
|
||||||
|
|
||||||
// todo : modularize the HTML in to separate files
|
|
||||||
|
|
||||||
echo '<?xml version="1.0" encoding="UTF-8" ?>';
|
|
||||||
?><!DOCTYPE html
|
|
||||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>HTML Purifier UTF-8 Smoketest</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
<link rel="stylesheet" href="allElements.css" type="text/css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
|
||||||
$config->set('Attr', 'EnableID', true);
|
|
||||||
|
|
||||||
$purifier = new HTMLPurifier($config);
|
|
||||||
echo $purifier->purify(file_get_contents('allElements.html'));
|
|
||||||
|
|
||||||
?>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
70
smoketests/basic.php
Normal file
70
smoketests/basic.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'common.php';
|
||||||
|
|
||||||
|
// todo : modularize the HTML in to separate files
|
||||||
|
|
||||||
|
$allowed = array(
|
||||||
|
'allElements' => true,
|
||||||
|
'legacy' => true
|
||||||
|
);
|
||||||
|
|
||||||
|
$page = isset($_GET['p']) ? $_GET['p'] : false;
|
||||||
|
if (!isset($allowed[$page])) $page = false;
|
||||||
|
|
||||||
|
$strict = isset($_GET['d']) ? (bool) $_GET['d'] : false;
|
||||||
|
|
||||||
|
echo '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||||
|
?>
|
||||||
|
<?php if ($strict) { ?>
|
||||||
|
<!DOCTYPE html
|
||||||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1- Strict.dtd">
|
||||||
|
<?php } else { ?>
|
||||||
|
<!DOCTYPE html
|
||||||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
|
||||||
|
<?php } ?>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>HTML Purifier Basic Smoketest</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<?php
|
||||||
|
if ($page) {
|
||||||
|
if (file_exists("basic/$page.css")) {
|
||||||
|
?><link rel="stylesheet" href="basic/<?php echo $page ?>.css" type="text/css" /><?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($page) {
|
||||||
|
?>
|
||||||
|
<div style="float:right;"><div><?php echo $strict ? 'Strict' : 'Loose'; ?>:
|
||||||
|
<a href="?d=<?php echo (int) !$strict; ?>&p=<?php echo $page ?>">Swap</a></div>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer"><img
|
||||||
|
src="http://www.w3.org/Icons/valid-xhtml10"
|
||||||
|
alt="Valid XHTML 1.0 Transitional" height="31" width="88" style="border:0;" /></a>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
|
$config->set('Attr', 'EnableID', true);
|
||||||
|
$config->set('HTML', 'Strict', $strict);
|
||||||
|
$purifier = new HTMLPurifier($config);
|
||||||
|
echo $purifier->purify(file_get_contents("basic/$page.html"));
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
<h1>HTML Purifier Basic Smoketest Index</h1>
|
||||||
|
<ul>
|
||||||
|
<?php
|
||||||
|
foreach ($allowed as $val => $b) {
|
||||||
|
?><li><a href="?p=<?php echo $val ?>"><?php echo $val ?></a></li><?php
|
||||||
|
}
|
||||||
|
?></ul><?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -4,15 +4,15 @@
|
|||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>HTML Purifier All Elements Smoketest Test Data</title>
|
<title>HTML Purifier All Elements Smoketest</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<link rel="stylesheet" href="allElements.css" type="text/css" />
|
<link rel="stylesheet" href="allElements.css" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>HTML Purifier All Elements Smoketest Test Data</h1>
|
<h1>HTML Purifier All Elements Smoketest</h1>
|
||||||
|
|
||||||
<p>This file includes all the test data for the all elements smoke
|
<p>This is the all elements smoke
|
||||||
test. It is divided by XHTML 1.1 style modules. Make sure
|
test. It is divided by XHTML 1.1 style modules. Make sure
|
||||||
<code>div</code>, <code>span</code> and <code>id</code> are allowed,
|
<code>div</code>, <code>span</code> and <code>id</code> are allowed,
|
||||||
otherwise there will be problems.</p>
|
otherwise there will be problems.</p>
|
32
smoketests/basic/legacy.css
Normal file
32
smoketests/basic/legacy.css
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
center,
|
||||||
|
dir[compact='compact'],
|
||||||
|
isindex[prompt='Foo'],
|
||||||
|
menu[compact='compact'],
|
||||||
|
s,
|
||||||
|
u,
|
||||||
|
strike,
|
||||||
|
|
||||||
|
caption[align='bottom'],
|
||||||
|
div[align='center'],
|
||||||
|
dl[compact='compact'],
|
||||||
|
|
||||||
|
h1[align='right'],
|
||||||
|
h2[align='right'],
|
||||||
|
h3[align='right'],
|
||||||
|
h4[align='right'],
|
||||||
|
h5[align='right'],
|
||||||
|
h6[align='right'],
|
||||||
|
|
||||||
|
hr[align='right'],
|
||||||
|
hr[noshade='noshade'],
|
||||||
|
hr[width='50'],
|
||||||
|
hr[size='50'],
|
||||||
|
|
||||||
|
.insert-declarations-above
|
||||||
|
{background:#008000; color:#FFF; font-weight:bold;}
|
||||||
|
|
||||||
|
font {background:#BFB;}
|
||||||
|
u {border:1px solid #000;}
|
||||||
|
hr {height:1em;}
|
||||||
|
hr[size='50'] {height:50px;}
|
101
smoketests/basic/legacy.html
Normal file
101
smoketests/basic/legacy.html
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE html
|
||||||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<title>HTML Purifier Legacy Smoketest Test Data</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<link rel="stylesheet" href="legacy.css" type="text/css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>HTML Purifier Legacy Smoketest Test Data</h1>
|
||||||
|
|
||||||
|
<p>This is the legacy smoketest.</p>
|
||||||
|
|
||||||
|
<h2>Elements</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<basefont color="green" face="Arial" size="6" id="basefont" />
|
||||||
|
basefont: Green, Arial, size 6 text (IE-only)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<center>center</center>
|
||||||
|
|
||||||
|
<dir compact="compact">
|
||||||
|
<li>dir</li>
|
||||||
|
</dir>
|
||||||
|
|
||||||
|
<font color="green" face="Arial" size="6">font: Green, Arial, size 6 text</font>
|
||||||
|
|
||||||
|
isindex:
|
||||||
|
<isindex prompt="Foo" />
|
||||||
|
|
||||||
|
<menu compact="compact">
|
||||||
|
<li>menu</li>
|
||||||
|
</menu>
|
||||||
|
|
||||||
|
<s>s</s> <strike>strike</strike> <u>u</u>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Attributes</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<!-- body -->
|
||||||
|
|
||||||
|
<div style="font-size:42pt; float:left;">*</div>
|
||||||
|
<br clear="left" />
|
||||||
|
<p>br@clear (asterisk is up)</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<caption align="bottom">caption@align</caption>
|
||||||
|
<tr><td>Cell</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div align="center">div@center</div>
|
||||||
|
|
||||||
|
<dl compact="compact">
|
||||||
|
<dt>dl@compact</dt>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h1 align="right">h1</h1>
|
||||||
|
<h2 align="right">h2</h2>
|
||||||
|
<h3 align="right">h3</h3>
|
||||||
|
<h4 align="right">h4</h4>
|
||||||
|
<h5 align="right">h5</h5>
|
||||||
|
<h6 align="right">h6</h6>
|
||||||
|
|
||||||
|
hr@align
|
||||||
|
<hr align="right" width="50" />
|
||||||
|
hr@noshade
|
||||||
|
<hr noshade="noshade" />
|
||||||
|
hr@width
|
||||||
|
<hr width="50" />
|
||||||
|
hr@size
|
||||||
|
<hr size="50" />
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
img& align ("top" | "middle" | "bottom" | "left" | "right"), border (Pixels), hspace (Pixels), vspace (Pixels)
|
||||||
|
input& align ("top" | "middle" | "bottom" | "left" | "right") When the Basic Forms or Forms Module is selected.
|
||||||
|
legend& align ("left" | "center" | "right" | "justify") When the Forms Module is selected.
|
||||||
|
li& type (CDATA), value (Number)
|
||||||
|
ol& compact ("compact"), start (Number), type (CDATA)
|
||||||
|
p& align ("left" | "center" | "right", "justify")
|
||||||
|
pre& width (Number)
|
||||||
|
script& language (CDATA) When the Scripting module is selected.
|
||||||
|
table& align ("left" | "center" | "right"), bgcolor (Color) When the Tables module is selected.
|
||||||
|
tr& bgcolor (Color) When the Tables module is selected.
|
||||||
|
th& bgcolor (Color), height (Length) nowrap ("nowrap"), width (Length) When the Tables module is selected.
|
||||||
|
td& bgcolor (Color), height (Length) nowrap ("nowrap"), width (Length) When the Tables module is selected.
|
||||||
|
ul& compact ("compact"), type (CDATA)
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user