0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-18 18:25:18 +00:00

[1.4.0] Implemented list-style-image, URIs now allowed in list-style

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@640 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-01-14 16:24:02 +00:00
parent 582ffc4143
commit 23d3490d49
4 changed files with 18 additions and 2 deletions

1
NEWS
View File

@ -10,6 +10,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
==========================
1.4.0, unknown release date
! Implemented list-style-image, URIs now allowed in list-style
. Implemented AttrDef_CSSURI for url(http://google.com) style declarations
1.3.3, unknown release date, likely to be dropped

View File

@ -20,6 +20,7 @@ class HTMLPurifier_AttrDef_ListStyle extends HTMLPurifier_AttrDef
$def = $config->getCSSDefinition();
$this->info['list-style-type'] = $def->info['list-style-type'];
$this->info['list-style-position'] = $def->info['list-style-position'];
$this->info['list-style-image'] = $def->info['list-style-image'];
}
function validate($string, $config, &$context) {
@ -32,13 +33,14 @@ class HTMLPurifier_AttrDef_ListStyle extends HTMLPurifier_AttrDef
$caught_type = false;
$caught_position = false;
$caught_image = false;
$caught_none = false; // as in keyword none, which is in all of them
$ret = '';
foreach ($bits as $bit) {
if ($caught_none && ($caught_type || $caught_position)) break;
if ($caught_type && $caught_position) break;
if ($caught_none && ($caught_type || $caught_position || $caught_image)) break;
if ($caught_type && $caught_position && $caught_image) break;
if ($bit === '') continue;
@ -66,6 +68,14 @@ class HTMLPurifier_AttrDef_ListStyle extends HTMLPurifier_AttrDef
$ret .= $r . ' ';
continue;
}
$r = $this->info['list-style-image']->validate($bit, $config, $context);
if ($r !== false) {
if ($caught_image) continue;
$caught_image = true;
$ret .= $r . ' ';
continue;
}
}
$ret = rtrim($ret);

View File

@ -11,6 +11,7 @@ require_once 'HTMLPurifier/AttrDef/FontFamily.php';
require_once 'HTMLPurifier/AttrDef/Font.php';
require_once 'HTMLPurifier/AttrDef/Border.php';
require_once 'HTMLPurifier/AttrDef/ListStyle.php';
require_once 'HTMLPurifier/AttrDef/CSSURI.php';
/**
* Defines allowed CSS attributes and what their values are.
@ -56,6 +57,7 @@ class HTMLPurifier_CSSDefinition
$this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum(
array('disc', 'circle', 'square', 'decimal', 'lower-roman',
'upper-roman', 'lower-alpha', 'upper-alpha'), false);
$this->info['list-style-image'] = new HTMLPurifier_AttrDef_CSSURI();
$this->info['list-style'] = new HTMLPurifier_AttrDef_ListStyle($config);

View File

@ -1,6 +1,7 @@
<?php
require_once 'HTMLPurifier/AttrDef/CSS.php';
require_once 'HTMLPurifier/AttrDefHarness.php';
class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
{
@ -71,6 +72,8 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('vertical-align:12px;');
$this->assertDef('vertical-align:50%;');
$this->assertDef('table-layout:fixed;');
$this->assertDef('list-style-image:url(nice.jpg);');
$this->assertDef('list-style:inside url(nice.jpg) disc;');
// duplicates
$this->assertDef('text-align:right;text-align:left;',