mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-31 20:01:52 +00:00
Commit text-decoration implementation.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@280 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
f36a05ce87
commit
cb463f9676
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/AttrDef.php';
|
||||||
|
|
||||||
// Enum = Enumerated
|
// Enum = Enumerated
|
||||||
class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef
|
class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef
|
||||||
{
|
{
|
||||||
|
32
library/HTMLPurifier/AttrDef/TextDecoration.php
Normal file
32
library/HTMLPurifier/AttrDef/TextDecoration.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/AttrDef.php';
|
||||||
|
|
||||||
|
class HTMLPurifier_AttrDef_TextDecoration extends HTMLPurifier_AttrDef
|
||||||
|
{
|
||||||
|
|
||||||
|
var $allowed_values = array(
|
||||||
|
'line-through' => true,
|
||||||
|
'overline' => true,
|
||||||
|
'underline' => true
|
||||||
|
);
|
||||||
|
|
||||||
|
function validate($string, $config, &$context) {
|
||||||
|
|
||||||
|
$string = strtolower($this->parseCDATA($string));
|
||||||
|
$parts = explode(' ', $string);
|
||||||
|
$final = '';
|
||||||
|
foreach ($parts as $part) {
|
||||||
|
if (isset($this->allowed_values[$part])) {
|
||||||
|
$final .= $part . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$final = rtrim($final);
|
||||||
|
if ($final === '') return false;
|
||||||
|
return $final;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -6,6 +6,7 @@ require_once 'HTMLPurifier/AttrDef/Composite.php';
|
|||||||
require_once 'HTMLPurifier/AttrDef/CSSLength.php';
|
require_once 'HTMLPurifier/AttrDef/CSSLength.php';
|
||||||
require_once 'HTMLPurifier/AttrDef/Percentage.php';
|
require_once 'HTMLPurifier/AttrDef/Percentage.php';
|
||||||
require_once 'HTMLPurifier/AttrDef/Multiple.php';
|
require_once 'HTMLPurifier/AttrDef/Multiple.php';
|
||||||
|
require_once 'HTMLPurifier/AttrDef/TextDecoration.php';
|
||||||
|
|
||||||
class HTMLPurifier_CSSDefinition
|
class HTMLPurifier_CSSDefinition
|
||||||
{
|
{
|
||||||
@ -140,6 +141,8 @@ class HTMLPurifier_CSSDefinition
|
|||||||
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$this->info['text-decoration'] = new HTMLPurifier_AttrDef_TextDecoration();
|
||||||
|
|
||||||
// this could use specialized code
|
// this could use specialized code
|
||||||
$this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
|
$this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
|
||||||
array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300',
|
array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300',
|
||||||
|
@ -57,6 +57,7 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
|
|||||||
$this->assertDef('width:50px;');
|
$this->assertDef('width:50px;');
|
||||||
$this->assertDef('width:auto;');
|
$this->assertDef('width:auto;');
|
||||||
$this->assertDef('width:-50px;', false);
|
$this->assertDef('width:-50px;', false);
|
||||||
|
$this->assertDef('text-decoration:underline;');
|
||||||
|
|
||||||
// duplicates
|
// duplicates
|
||||||
$this->assertDef('text-align:right;text-align:left;',
|
$this->assertDef('text-align:right;text-align:left;',
|
||||||
|
27
tests/HTMLPurifier/AttrDef/TextDecorationTest.php
Normal file
27
tests/HTMLPurifier/AttrDef/TextDecorationTest.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/AttrDefHarness.php';
|
||||||
|
require_once 'HTMLPurifier/AttrDef/TextDecoration.php';
|
||||||
|
|
||||||
|
class HTMLPurifier_AttrDef_TextDecorationTest extends HTMLPurifier_AttrDefHarness
|
||||||
|
{
|
||||||
|
|
||||||
|
function testCaseInsensitive() {
|
||||||
|
|
||||||
|
$this->def = new HTMLPurifier_AttrDef_TextDecoration();
|
||||||
|
|
||||||
|
$this->assertDef('underline');
|
||||||
|
$this->assertDef('overline');
|
||||||
|
$this->assertDef('line-through overline underline');
|
||||||
|
$this->assertDef('overline line-through');
|
||||||
|
$this->assertDef('UNDERLINE', 'underline');
|
||||||
|
$this->assertDef(' underline line-through ', 'underline line-through');
|
||||||
|
|
||||||
|
$this->assertDef('foobar underline', 'underline');
|
||||||
|
$this->assertDef('blink', false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -71,6 +71,7 @@ $test_files[] = 'AttrDef/NumberTest.php';
|
|||||||
$test_files[] = 'AttrDef/CSSLengthTest.php';
|
$test_files[] = 'AttrDef/CSSLengthTest.php';
|
||||||
$test_files[] = 'AttrDef/PercentageTest.php';
|
$test_files[] = 'AttrDef/PercentageTest.php';
|
||||||
$test_files[] = 'AttrDef/MultipleTest.php';
|
$test_files[] = 'AttrDef/MultipleTest.php';
|
||||||
|
$test_files[] = 'AttrDef/TextDecorationTest.php';
|
||||||
$test_files[] = 'IDAccumulatorTest.php';
|
$test_files[] = 'IDAccumulatorTest.php';
|
||||||
$test_files[] = 'TagTransformTest.php';
|
$test_files[] = 'TagTransformTest.php';
|
||||||
$test_files[] = 'AttrTransform/LangTest.php';
|
$test_files[] = 'AttrTransform/LangTest.php';
|
||||||
|
Loading…
Reference in New Issue
Block a user