mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-02-02 18:10:01 +00:00
Tack on missing basic smoketests.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1180 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
0101311193
commit
5ecb11f19a
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>
|
48
smoketests/basic/allElements.css
Normal file
48
smoketests/basic/allElements.css
Normal file
@ -0,0 +1,48 @@
|
||||
div > * {background:#F00; color:#FFF; font-weight:bold; padding:0.2em; margin:0.1em;}
|
||||
#core-attributes #core-attributes-id,
|
||||
#core-attributes .core-attributes-class,
|
||||
#core-attributes div[title='tooltip'],
|
||||
#core-attributes div[lang='en'],
|
||||
#core-attributes div[onclick="alert('foo');"],
|
||||
#module-text abbr,
|
||||
#module-text acronym,
|
||||
#module-text div blockquote,
|
||||
#module-text blockquote[cite='http://www.example.com'],
|
||||
#module-text br,
|
||||
#module-text cite,
|
||||
#module-text code,
|
||||
#module-text dfn,
|
||||
#module-text em,
|
||||
#module-text h1,
|
||||
#module-text h2,
|
||||
#module-text h3,
|
||||
#module-text h4,
|
||||
#module-text h5,
|
||||
#module-text h6,
|
||||
#module-text kbd,
|
||||
#module-text p,
|
||||
#module-text pre,
|
||||
#module-text span q,
|
||||
#module-text q[cite='http://www.example.com'],
|
||||
#module-text samp,
|
||||
#module-text strong,
|
||||
#module-text var,
|
||||
#module-hypertext span a,
|
||||
#module-hypertext a[accesskey='q'],
|
||||
#module-hypertext a[charset='UTF-8'],
|
||||
#module-hypertext a[href='http://www.example.com/'],
|
||||
#module-hypertext a[hreflang='en'],
|
||||
#module-hypertext a[rel='nofollow'],
|
||||
#module-hypertext a[rev='index'],
|
||||
#module-hypertext a[tabindex='1'],
|
||||
#module-hypertext a[type='text/plain'],
|
||||
#module-list dl,
|
||||
#module-list ul,
|
||||
#module-list ol,
|
||||
#module-list li,
|
||||
#module-list dd,
|
||||
#module-list dt,
|
||||
.insert-declarations-above
|
||||
{background:#008000; margin:0; padding:0.2em;}
|
||||
#module-text span, #module-text div {padding:0; margin:0.1em;}
|
||||
#module-list li, #module-list dd, #module-list dt {border:1px solid #FFF;}
|
79
smoketests/basic/allElements.html
Normal file
79
smoketests/basic/allElements.html
Normal file
@ -0,0 +1,79 @@
|
||||
<?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 All Elements Smoketest</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="stylesheet" href="allElements.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>HTML Purifier All Elements Smoketest</h1>
|
||||
|
||||
<p>This is the all elements smoke
|
||||
test. It is divided by XHTML 1.1 style modules. Make sure
|
||||
<code>div</code>, <code>span</code> and <code>id</code> are allowed,
|
||||
otherwise there will be problems.</p>
|
||||
|
||||
<h2>Core attributes</h2>
|
||||
<div id="core-attributes">
|
||||
<div id="core-attributes-id">id</div>
|
||||
<div class="core-attributes-class">class</div>
|
||||
<div title="tooltip">title</div>
|
||||
<div lang="en">lang</div>
|
||||
<div xml:lang="en">xml:lang (green when lang also present)</div>
|
||||
<div style="background:#008000">style</div>
|
||||
<div onclick="alert('foo');">onclick (and other event handlers)</div>
|
||||
</div>
|
||||
|
||||
<h2>Text module</h2>
|
||||
<div id="module-text">
|
||||
<abbr>abbr</abbr>
|
||||
<acronym>acronym</acronym>
|
||||
<div><blockquote>blockquote</blockquote></div>
|
||||
<blockquote cite="http://www.example.com">blockquote@cite</blockquote>
|
||||
<br />
|
||||
<cite>cite</cite>
|
||||
<code>code</code>
|
||||
<dfn>dfn</dfn>
|
||||
<em>em</em>
|
||||
<h1>h1</h1>
|
||||
<h2>h2</h2>
|
||||
<h3>h3</h3>
|
||||
<h4>h4</h4>
|
||||
<h5>h5</h5>
|
||||
<h6>h6</h6>
|
||||
<kbd>kbd</kbd>
|
||||
<p>p</p>
|
||||
<pre>pre</pre>
|
||||
<span><q>q</q></span>
|
||||
<q cite="http://www.example.com">q@cite</q>
|
||||
<samp>samp</samp>
|
||||
<strong>strong</strong>
|
||||
<var>var</var>
|
||||
</div>
|
||||
|
||||
<h2>Hypertext module</h2>
|
||||
<div id="module-hypertext">
|
||||
<span><a>a</a></span>:
|
||||
<a accesskey="q">accesskey</a>
|
||||
<a charset="UTF-8">charset</a>
|
||||
<a href="http://www.example.com/">href</a>
|
||||
<a hreflang="en">hreflang</a>
|
||||
<a rel="nofollow">rel</a>
|
||||
<a rev="index">rev</a>
|
||||
<a tabindex="1">tabindex</a>
|
||||
<a type="text/plain">type</a>
|
||||
</div>
|
||||
|
||||
<h2>List module</h2>
|
||||
<div id="module-list">
|
||||
<dl><dt>dl dt</dt><dd>dl dd</dd></dl>
|
||||
<ol><li>ol li</li></ol>
|
||||
<ul><li>ul li</li></ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
71
smoketests/basic/legacy.css
Normal file
71
smoketests/basic/legacy.css
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
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'],
|
||||
|
||||
img[align='right'],
|
||||
img[border='3'],
|
||||
img[hspace='5'],
|
||||
img[vspace='5'],
|
||||
|
||||
input[align='right'],
|
||||
legend[align='center'],
|
||||
|
||||
li[type='A'],
|
||||
li[value='5'],
|
||||
|
||||
ol[compact='compact'],
|
||||
ol[start='3'],
|
||||
ol[type='I'],
|
||||
|
||||
p[align='right'],
|
||||
|
||||
pre[width='50'],
|
||||
|
||||
table[align='right'],
|
||||
table[bgcolor='#0000FF'],
|
||||
|
||||
tr[bgcolor='#0000FF'],
|
||||
|
||||
td[bgcolor='#0000FF'],
|
||||
td[height='50'],
|
||||
td[nowrap='nowrap'],
|
||||
td[width='200'],
|
||||
|
||||
th[bgcolor='#0000FF'],
|
||||
th[height='50'],
|
||||
th[nowrap='nowrap'],
|
||||
th[width='200'],
|
||||
|
||||
ul[compact='compact'],
|
||||
ul[type='square'],
|
||||
|
||||
.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;}
|
||||
img[border='3'] {border: 3px solid #000;}
|
||||
li[type='a'], li[value='5'] {color:#DDD;}
|
124
smoketests/basic/legacy.html
Normal file
124
smoketests/basic/legacy.html
Normal file
@ -0,0 +1,124 @@
|
||||
<?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" />
|
||||
|
||||
<img src="" alt="img@align" align="right" /> |
|
||||
<img src="" alt="img@border" border="3" /> |
|
||||
<img src="" alt="img@hspace" hspace="5" /> |
|
||||
<img src="" alt="img@vspace" vspace="5" />
|
||||
|
||||
<!-- needs context -->
|
||||
<input align="right" />
|
||||
<legend align="center">Legend</legend>
|
||||
|
||||
<ol>
|
||||
<li type="A">li@type (ensure that it's a capital A)</li>
|
||||
<li value="5">li@value</li>
|
||||
</ol>
|
||||
|
||||
<ol compact="compact"><li>ol@compact</li></ol>
|
||||
<ol start="3"><li>ol@start</li></ol>
|
||||
<ol type="I"><li>ol@type</li></ol>
|
||||
|
||||
<p align="right">p@align</p>
|
||||
|
||||
<pre width="50">pre@width</pre>
|
||||
|
||||
<script language="JavaScript">document.writeln('script');</script>
|
||||
|
||||
<table align="right"><tr><td>table@align</td></tr></table>
|
||||
<table bgcolor="#0000FF"><tr><td>table@bgcolor</td></tr></table>
|
||||
|
||||
<table><tr bgcolor="#0000FF"><td>tr@bgcolor</td></tr></table>
|
||||
|
||||
<table><tr><td bgcolor="#0000FF">td@bgcolor</td></tr></table>
|
||||
<table><tr><td height="50">td@height</td></tr></table>
|
||||
<table><tr><td nowrap="nowrap">td@nowrap</td></tr></table>
|
||||
<table><tr><td width="200">td@width</td></tr></table>
|
||||
|
||||
<table><tr><th bgcolor="#0000FF">th@bgcolor</th></tr></table>
|
||||
<table><tr><th height="50">th@height</th></tr></table>
|
||||
<table><tr><th nowrap="nowrap">th@nowrap</th></tr></table>
|
||||
<table><tr><th width="200">th@width</th></tr></table>
|
||||
|
||||
<ul compact="compact"><li>ul@compact</li></ul>
|
||||
<ul type="square"><li>ul@square</li></ul>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user