mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 05:11:52 +00:00
Add extractStyleBlocks.php smoketest, also add some neat new functionality to TODO.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1471 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
5b3431d889
commit
66c0407bef
4
TODO
4
TODO
@ -13,6 +13,10 @@ afraid to cast your vote for the next feature to be implemented!
|
|||||||
|
|
||||||
3.0 release [Go PHP5!]
|
3.0 release [Go PHP5!]
|
||||||
- Convert all &$context calls to $context, as PHP5 passes objects by value
|
- Convert all &$context calls to $context, as PHP5 passes objects by value
|
||||||
|
- Allow extracted CSS blocks to have a bounding selector prepended to all
|
||||||
|
of their declarations. There are two types: a global type and a HTML5
|
||||||
|
scoped type. This will allow for <style> while minimizing the risk of
|
||||||
|
disruption of other parts of site layout,
|
||||||
|
|
||||||
3.1 release [Error'ed]
|
3.1 release [Error'ed]
|
||||||
# Error logging for filtering/cleanup procedures
|
# Error logging for filtering/cleanup procedures
|
||||||
|
69
smoketests/extractStyleBlocks.php
Normal file
69
smoketests/extractStyleBlocks.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'common.php';
|
||||||
|
require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
|
||||||
|
|
||||||
|
// need CSSTidy location
|
||||||
|
$csstidy_location = false;
|
||||||
|
if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php';
|
||||||
|
if (file_exists('../test-settings.php')) include '../test-settings.php';
|
||||||
|
|
||||||
|
if (!$csstidy_location) {
|
||||||
|
?>
|
||||||
|
Error: <a href="http://csstidy.sourceforge.net/">CSSTidy</a> library not
|
||||||
|
found, please install and configure <code>test-settings.php</code>
|
||||||
|
accordingly.
|
||||||
|
<?php
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $csstidy_location . 'class.csstidy.php';
|
||||||
|
require_once $csstidy_location . 'class.csstidy_print.php';
|
||||||
|
|
||||||
|
$purifier = new HTMLPurifier();
|
||||||
|
$purifier->addFilter(new HTMLPurifier_Filter_ExtractStyleBlocks());
|
||||||
|
|
||||||
|
$html = isset($_POST['html']) ? $_POST['html'] : '';
|
||||||
|
$purified_html = $purifier->purify($html);
|
||||||
|
|
||||||
|
?><!DOCTYPE html
|
||||||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Extract Style Blocks - HTML Purifier Smoketest</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// generate style blocks
|
||||||
|
foreach ($purifier->context->get('StyleBlocks') as $style) {
|
||||||
|
?><style type="text/css">
|
||||||
|
<!--/*--><![CDATA[/*><!--*/
|
||||||
|
<?php echo $style; ?>
|
||||||
|
|
||||||
|
/*]]>*/-->
|
||||||
|
</style>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Extract Style Blocks</h1>
|
||||||
|
<p>
|
||||||
|
This smoketest allows users to specify global style sheets for the
|
||||||
|
document, allowing for interesting techniques and compact markup
|
||||||
|
that wouldn't normally be possible, using the ExtractStyleBlocks filter.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
User submitted content:
|
||||||
|
</p>
|
||||||
|
<div style="border: 1px solid #CCC; margin: 1em; padding: 1em;">
|
||||||
|
<?php echo $purified_html ?>
|
||||||
|
</div>
|
||||||
|
<form action="" method="post">
|
||||||
|
<textarea cols="100" rows="20" name="html"><?php echo escapeHTML($html) ?></textarea>
|
||||||
|
<input type="submit" value="Submit" />
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user