first commit
This commit is contained in:
28
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/AlphaValueTest.php
Executable file
28
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/AlphaValueTest.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_AlphaValueTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_AlphaValue();
|
||||
|
||||
$this->assertDef('0');
|
||||
$this->assertDef('1');
|
||||
$this->assertDef('.2');
|
||||
|
||||
// clamping to [0.0, 1,0]
|
||||
$this->assertDef('1.2', '1');
|
||||
$this->assertDef('-3', '0');
|
||||
|
||||
$this->assertDef('0.0', '0');
|
||||
$this->assertDef('1.0', '1');
|
||||
$this->assertDef('000', '0');
|
||||
|
||||
$this->assertDef('asdf', false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_BackgroundPositionTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
|
||||
|
||||
// explicitly cited in spec
|
||||
$this->assertDef('0% 0%');
|
||||
$this->assertDef('100% 100%');
|
||||
$this->assertDef('14% 84%');
|
||||
$this->assertDef('2cm 1cm');
|
||||
$this->assertDef('top');
|
||||
$this->assertDef('left');
|
||||
$this->assertDef('center');
|
||||
$this->assertDef('right');
|
||||
$this->assertDef('bottom');
|
||||
$this->assertDef('left top');
|
||||
$this->assertDef('center top');
|
||||
$this->assertDef('right top');
|
||||
$this->assertDef('left center');
|
||||
$this->assertDef('right center');
|
||||
$this->assertDef('left bottom');
|
||||
$this->assertDef('center bottom');
|
||||
$this->assertDef('right bottom');
|
||||
|
||||
// reordered due to internal impl details
|
||||
$this->assertDef('top left', 'left top');
|
||||
$this->assertDef('top center', 'top');
|
||||
$this->assertDef('top right', 'right top');
|
||||
$this->assertDef('center left', 'left');
|
||||
$this->assertDef('center center', 'center');
|
||||
$this->assertDef('center right', 'right');
|
||||
$this->assertDef('bottom left', 'left bottom');
|
||||
$this->assertDef('bottom center', 'bottom');
|
||||
$this->assertDef('bottom right', 'right bottom');
|
||||
|
||||
// more cases from the defined syntax
|
||||
$this->assertDef('1.32in 4ex');
|
||||
$this->assertDef('-14% -84.65%');
|
||||
$this->assertDef('-1in -4ex');
|
||||
$this->assertDef('-1pc 2.3%');
|
||||
|
||||
// keyword mixing
|
||||
$this->assertDef('3em top');
|
||||
$this->assertDef('left 50%');
|
||||
|
||||
// fixable keyword mixing
|
||||
$this->assertDef('top 3em', '3em top');
|
||||
$this->assertDef('50% left', 'left 50%');
|
||||
|
||||
// whitespace collapsing
|
||||
$this->assertDef('3em top', '3em top');
|
||||
$this->assertDef("left\n \t foo ", 'left');
|
||||
|
||||
// invalid uses (we're going to be strict on these)
|
||||
$this->assertDef('foo bar', false);
|
||||
$this->assertDef('left left', 'left');
|
||||
$this->assertDef('left right top bottom center left', 'left bottom');
|
||||
$this->assertDef('0fr 9%', '9%');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php
Executable file
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_BackgroundTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Background($config);
|
||||
|
||||
$valid = '#333 url("chess.png") repeat fixed 50% top';
|
||||
$this->assertDef($valid);
|
||||
$this->assertDef('url(\'chess.png\') #333 50% top repeat fixed', $valid);
|
||||
$this->assertDef(
|
||||
'rgb(34%, 56%, 33%) url(chess.png) repeat fixed top',
|
||||
'rgb(34%,56%,33%) url("chess.png") repeat fixed top'
|
||||
);
|
||||
$this->assertDef(
|
||||
'rgba(74, 12, 85, 0.35) repeat fixed bottom',
|
||||
'rgba(74,12,85,.35) repeat fixed bottom'
|
||||
);
|
||||
$this->assertDef(
|
||||
'hsl(244, 47.4%, 88.1%) right center',
|
||||
'hsl(244,47.4%,88.1%) right center'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
21
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php
Executable file
21
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_BorderTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Border($config);
|
||||
|
||||
$this->assertDef('thick solid red', 'thick solid #FF0000');
|
||||
$this->assertDef('thick solid');
|
||||
$this->assertDef('solid red', 'solid #FF0000');
|
||||
$this->assertDef('1px solid #000');
|
||||
$this->assertDef('1px solid rgb(0, 0, 0)', '1px solid rgb(0,0,0)');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
61
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php
Executable file
61
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php
Executable file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_ColorTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Color();
|
||||
|
||||
$this->assertDef('#F00');
|
||||
$this->assertDef('#fff');
|
||||
$this->assertDef('#eeeeee');
|
||||
$this->assertDef('#808080');
|
||||
|
||||
$this->assertDef('rgb(255, 0, 0)', 'rgb(255,0,0)'); // rm spaces
|
||||
$this->assertDef('rgb(100%,0%,0%)');
|
||||
$this->assertDef('rgb(50.5%,23.2%,43.9%)'); // decimals okay
|
||||
$this->assertDef('rgb(-5,0,0)', 'rgb(0,0,0)'); // negative values
|
||||
$this->assertDef('rgb(295,0,0)', 'rgb(255,0,0)'); // max values
|
||||
$this->assertDef('rgb(12%,150%,0%)', 'rgb(12%,100%,0%)'); // percentage max values
|
||||
|
||||
$this->assertDef('rgba(255, 0, 0, 0)', 'rgba(255,0,0,0)'); // rm spaces
|
||||
$this->assertDef('rgba(100%,0%,0%,.4)');
|
||||
$this->assertDef('rgba(38.1%,59.7%,1.8%,0.7)', 'rgba(38.1%,59.7%,1.8%,.7)'); // decimals okay
|
||||
|
||||
$this->assertDef('hsl(275, 45%, 81%)', 'hsl(275,45%,81%)'); // rm spaces
|
||||
$this->assertDef('hsl(100,0%,0%)');
|
||||
$this->assertDef('hsl(38,59.7%,1.8%)', 'hsl(38,59.7%,1.8%)'); // decimals okay
|
||||
$this->assertDef('hsl(-11,-15%,25%)', 'hsl(0,0%,25%)'); // negative values
|
||||
$this->assertDef('hsl(380,125%,0%)', 'hsl(360,100%,0%)'); // max values
|
||||
|
||||
$this->assertDef('hsla(100, 74%, 29%, 0)', 'hsla(100,74%,29%,0)'); // rm spaces
|
||||
$this->assertDef('hsla(154,87%,21%,.4)');
|
||||
$this->assertDef('hsla(45,94.3%,4.1%,0.7)', 'hsla(45,94.3%,4.1%,.7)'); // decimals okay
|
||||
|
||||
$this->assertDef('#G00', false);
|
||||
$this->assertDef('cmyk(40, 23, 43, 23)', false);
|
||||
$this->assertDef('rgb(0%, 23, 68%)', false); // no mixed type
|
||||
$this->assertDef('rgb(231, 144, 28.2%)', false); // no mixed type
|
||||
$this->assertDef('hsl(18%,12%,89%)', false); // integer, percentage, percentage
|
||||
|
||||
// clip numbers outside sRGB gamut
|
||||
$this->assertDef('rgb(200%, -10%, 0%)', 'rgb(100%,0%,0%)');
|
||||
$this->assertDef('rgb(256,-23,34)', 'rgb(255,0,34)');
|
||||
|
||||
// color keywords, of course
|
||||
$this->assertDef('red', '#FF0000');
|
||||
|
||||
// malformed hex declaration
|
||||
$this->assertDef('808080', '#808080');
|
||||
$this->assertDef('000000', '#000000');
|
||||
$this->assertDef('fed', '#fed');
|
||||
|
||||
// maybe hex transformations would be another nice feature
|
||||
// at the very least transform rgb percent to rgb integer
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
82
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php
Executable file
82
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php
Executable file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_Composite_Testable extends
|
||||
HTMLPurifier_AttrDef_CSS_Composite
|
||||
{
|
||||
|
||||
// we need to pass by ref to get the mocks in
|
||||
public function __construct(&$defs)
|
||||
{
|
||||
$this->defs =& $defs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
protected $def1, $def2;
|
||||
|
||||
public function test()
|
||||
{
|
||||
generate_mock_once('HTMLPurifier_AttrDef');
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
// first test: value properly validates on first definition
|
||||
// so second def is never called
|
||||
|
||||
$def1 = new HTMLPurifier_AttrDefMock();
|
||||
$def2 = new HTMLPurifier_AttrDefMock();
|
||||
$defs = array(&$def1, &$def2);
|
||||
$def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
|
||||
$input = 'FOOBAR';
|
||||
$output = 'foobar';
|
||||
$def1_params = array($input, $config, $context);
|
||||
$def1->expectOnce('validate', $def1_params);
|
||||
$def1->returns('validate', $output, $def1_params);
|
||||
$def2->expectNever('validate');
|
||||
|
||||
$result = $def->validate($input, $config, $context);
|
||||
$this->assertIdentical($output, $result);
|
||||
|
||||
// second test, first def fails, second def works
|
||||
|
||||
$def1 = new HTMLPurifier_AttrDefMock();
|
||||
$def2 = new HTMLPurifier_AttrDefMock();
|
||||
$defs = array(&$def1, &$def2);
|
||||
$def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
|
||||
$input = 'BOOMA';
|
||||
$output = 'booma';
|
||||
$def_params = array($input, $config, $context);
|
||||
$def1->expectOnce('validate', $def_params);
|
||||
$def1->returns('validate', false, $def_params);
|
||||
$def2->expectOnce('validate', $def_params);
|
||||
$def2->returns('validate', $output, $def_params);
|
||||
|
||||
$result = $def->validate($input, $config, $context);
|
||||
$this->assertIdentical($output, $result);
|
||||
|
||||
// third test, all fail, so composite faiils
|
||||
|
||||
$def1 = new HTMLPurifier_AttrDefMock();
|
||||
$def2 = new HTMLPurifier_AttrDefMock();
|
||||
$defs = array(&$def1, &$def2);
|
||||
$def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
|
||||
$input = 'BOOMA';
|
||||
$output = false;
|
||||
$def_params = array($input, $config, $context);
|
||||
$def1->expectOnce('validate', $def_params);
|
||||
$def1->returns('validate', false, $def_params);
|
||||
$def2->expectOnce('validate', $def_params);
|
||||
$def2->returns('validate', false, $def_params);
|
||||
|
||||
$result = $def->validate($input, $config, $context);
|
||||
$this->assertIdentical($output, $result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/FilterTest.php
Executable file
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/FilterTest.php
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_FilterTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Filter();
|
||||
|
||||
$this->assertDef('none');
|
||||
|
||||
$this->assertDef('alpha(opacity=0)');
|
||||
$this->assertDef('alpha(opacity=100)');
|
||||
$this->assertDef('alpha(opacity=50)');
|
||||
$this->assertDef('alpha(opacity=342)', 'alpha(opacity=100)');
|
||||
$this->assertDef('alpha(opacity=-23)', 'alpha(opacity=0)');
|
||||
|
||||
$this->assertDef('alpha ( opacity = 0 )', 'alpha(opacity=0)');
|
||||
$this->assertDef('alpha(opacity=0,opacity=100)', 'alpha(opacity=0)');
|
||||
|
||||
$this->assertDef('progid:DXImageTransform.Microsoft.Alpha(opacity=20)');
|
||||
|
||||
$this->assertDef('progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)', false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
53
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php
Executable file
53
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php
Executable file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_FontFamilyTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_FontFamily();
|
||||
|
||||
$this->assertDef('Gill, Helvetica, sans-serif');
|
||||
$this->assertDef("'Times New Roman', serif");
|
||||
$this->assertDef("\"Times New Roman\"", "'Times New Roman'");
|
||||
$this->assertDef('01234');
|
||||
$this->assertDef(',', false);
|
||||
$this->assertDef('Times New Roman, serif', "'Times New Roman', serif");
|
||||
$this->assertDef($d = "'\xE5\xAE\x8B\xE4\xBD\x93'");
|
||||
$this->assertDef("\xE5\xAE\x8B\xE4\xBD\x93", $d);
|
||||
$this->assertDef("'\\01'", "''");
|
||||
$this->assertDef("'\\20'", "' '");
|
||||
$this->assertDef("\\0020", "' '");
|
||||
$this->assertDef("'\\000045'", "E");
|
||||
$this->assertDef("','", false);
|
||||
$this->assertDef("',' foobar','", "' foobar'");
|
||||
$this->assertDef("'\\000045a'", "Ea");
|
||||
$this->assertDef("'\\00045 a'", "Ea");
|
||||
$this->assertDef("'\\00045 a'", "'E a'");
|
||||
$this->assertDef("'\\\nf'", "f");
|
||||
// No longer supported, except maybe in NoJS mode (see source
|
||||
// file for more explanation)
|
||||
//$this->assertDef($d = '"John\'s Font"');
|
||||
//$this->assertDef("John's Font", $d);
|
||||
//$this->assertDef("'\\','f'", "\"\\5C \", f");
|
||||
//$this->assertDef("'\\27'", "\"'\"");
|
||||
//$this->assertDef('"\\22"', "\"\\22 \"");
|
||||
//$this->assertDef('"\\""', "\"\\22 \"");
|
||||
//$this->assertDef('"\'"', "\"'\"");
|
||||
}
|
||||
|
||||
public function testAllowed()
|
||||
{
|
||||
$this->config->set('CSS.AllowedFonts', array('serif', 'Times New Roman'));
|
||||
|
||||
$this->assertDef('serif');
|
||||
$this->assertDef('sans-serif', false);
|
||||
$this->assertDef('serif, sans-serif', 'serif');
|
||||
$this->assertDef('Times New Roman', "'Times New Roman'");
|
||||
$this->assertDef("'Times New Roman'");
|
||||
$this->assertDef('foo', false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
34
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/FontTest.php
Executable file
34
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/FontTest.php
Executable file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_FontTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Font($config);
|
||||
|
||||
// hodgepodge of usage cases from W3C spec, but " -> '
|
||||
$this->assertDef('12px/14px sans-serif');
|
||||
$this->assertDef('80% sans-serif');
|
||||
$this->assertDef("x-large/110% 'New Century Schoolbook', serif");
|
||||
$this->assertDef('bold italic large Palatino, serif');
|
||||
$this->assertDef('normal small-caps 120%/120% fantasy');
|
||||
$this->assertDef("300 italic 1.3em/1.7em 'FB Armada', sans-serif");
|
||||
$this->assertDef('600 9px Charcoal');
|
||||
$this->assertDef('600 9px/ 12px Charcoal', '600 9px/12px Charcoal');
|
||||
|
||||
// spacing
|
||||
$this->assertDef('12px / 14px sans-serif', '12px/14px sans-serif');
|
||||
|
||||
// system fonts
|
||||
$this->assertDef('menu');
|
||||
|
||||
$this->assertDef('800', false);
|
||||
$this->assertDef('600 9px//12px Charcoal', false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_ImportantDecoratorTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
/** Mock AttrDef decorator is wrapping */
|
||||
protected $mock;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
generate_mock_once('HTMLPurifier_AttrDef');
|
||||
$this->mock = new HTMLPurifier_AttrDefMock();
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($this->mock, true);
|
||||
}
|
||||
|
||||
protected function setMock($input, $output = null)
|
||||
{
|
||||
if ($output === null) $output = $input;
|
||||
$this->mock->expectOnce('validate', array($input, $this->config, $this->context));
|
||||
$this->mock->returns('validate', $output);
|
||||
}
|
||||
|
||||
public function testImportant()
|
||||
{
|
||||
$this->setMock('23');
|
||||
$this->assertDef('23 !important');
|
||||
}
|
||||
|
||||
public function testImportantInternalDefChanged()
|
||||
{
|
||||
$this->setMock('23', '24');
|
||||
$this->assertDef('23 !important', '24 !important');
|
||||
}
|
||||
|
||||
public function testImportantWithSpace()
|
||||
{
|
||||
$this->setMock('23');
|
||||
$this->assertDef('23 ! important ', '23 !important');
|
||||
}
|
||||
|
||||
public function testFakeImportant()
|
||||
{
|
||||
$this->setMock('! foo important');
|
||||
$this->assertDef('! foo important');
|
||||
}
|
||||
|
||||
public function testStrip()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($this->mock, false);
|
||||
$this->setMock('23');
|
||||
$this->assertDef('23 ! important ', '23');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
49
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php
Executable file
49
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_LengthTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Length();
|
||||
|
||||
$this->assertDef('0');
|
||||
$this->assertDef('0px');
|
||||
$this->assertDef('4.5px');
|
||||
$this->assertDef('-4.5px');
|
||||
$this->assertDef('3ex');
|
||||
$this->assertDef('3em');
|
||||
$this->assertDef('3in');
|
||||
$this->assertDef('3cm');
|
||||
$this->assertDef('3mm');
|
||||
$this->assertDef('3pt');
|
||||
$this->assertDef('3pc');
|
||||
|
||||
$this->assertDef('3PX', '3px');
|
||||
|
||||
$this->assertDef('3', false);
|
||||
$this->assertDef('3miles', false);
|
||||
|
||||
}
|
||||
|
||||
public function testNonNegative()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Length('0');
|
||||
|
||||
$this->assertDef('3cm');
|
||||
$this->assertDef('-3mm', false);
|
||||
|
||||
}
|
||||
|
||||
public function testBounding()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Length('-1in', '1in');
|
||||
$this->assertDef('1cm');
|
||||
$this->assertDef('-1cm');
|
||||
$this->assertDef('0');
|
||||
$this->assertDef('1em', false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
35
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php
Executable file
35
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php
Executable file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_ListStyleTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_ListStyle($config);
|
||||
|
||||
$this->assertDef('lower-alpha');
|
||||
$this->assertDef('upper-roman inside');
|
||||
$this->assertDef('circle outside');
|
||||
$this->assertDef('inside');
|
||||
$this->assertDef('none');
|
||||
$this->assertDef('url("foo.gif")');
|
||||
$this->assertDef('circle url("foo.gif") inside');
|
||||
|
||||
// invalid values
|
||||
$this->assertDef('outside inside', 'outside');
|
||||
|
||||
// ordering
|
||||
$this->assertDef('url(foo.gif) none', 'none url("foo.gif")');
|
||||
$this->assertDef('circle lower-alpha', 'circle');
|
||||
// the spec is ambiguous about what happens in these
|
||||
// cases, so we're going off the W3C CSS validator
|
||||
$this->assertDef('disc none', 'disc');
|
||||
$this->assertDef('none disc', 'none');
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php
Executable file
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
// borrowed for the sakes of this test
|
||||
class HTMLPurifier_AttrDef_CSS_MultipleTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Multiple(
|
||||
new HTMLPurifier_AttrDef_Integer()
|
||||
);
|
||||
|
||||
$this->assertDef('1 2 3 4');
|
||||
$this->assertDef('6');
|
||||
$this->assertDef('4 5');
|
||||
$this->assertDef(' 2 54 2 3', '2 54 2 3');
|
||||
$this->assertDef("6\r3", '6 3');
|
||||
|
||||
$this->assertDef('asdf', false);
|
||||
$this->assertDef('a s d f', false);
|
||||
$this->assertDef('1 2 3 4 5', '1 2 3 4');
|
||||
$this->assertDef('1 2 invalid 3', '1 2 3');
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
51
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php
Executable file
51
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_NumberTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Number();
|
||||
|
||||
$this->assertDef('0');
|
||||
$this->assertDef('0.0', '0');
|
||||
$this->assertDef('1.0', '1');
|
||||
$this->assertDef('34');
|
||||
$this->assertDef('4.5');
|
||||
$this->assertDef('.5');
|
||||
$this->assertDef('0.5', '.5');
|
||||
$this->assertDef('-56.9');
|
||||
|
||||
$this->assertDef('0.', '0');
|
||||
$this->assertDef('.0', '0');
|
||||
$this->assertDef('0.0', '0');
|
||||
|
||||
$this->assertDef('1.', '1');
|
||||
$this->assertDef('.1', '.1');
|
||||
|
||||
$this->assertDef('1.0', '1');
|
||||
$this->assertDef('0.1', '.1');
|
||||
|
||||
$this->assertDef('000', '0');
|
||||
$this->assertDef(' 9', '9');
|
||||
$this->assertDef('+5.0000', '5');
|
||||
$this->assertDef('02.20', '2.2');
|
||||
$this->assertDef('2.', '2');
|
||||
|
||||
$this->assertDef('.', false);
|
||||
$this->assertDef('asdf', false);
|
||||
$this->assertDef('0.5.6', false);
|
||||
|
||||
}
|
||||
|
||||
public function testNonNegative()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Number(true);
|
||||
$this->assertDef('23');
|
||||
$this->assertDef('-12', false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
24
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php
Executable file
24
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php
Executable file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_PercentageTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_Percentage();
|
||||
|
||||
$this->assertDef('10%');
|
||||
$this->assertDef('1.607%');
|
||||
$this->assertDef('-567%');
|
||||
|
||||
$this->assertDef(' 100% ', '100%');
|
||||
|
||||
$this->assertDef('5', false);
|
||||
$this->assertDef('asdf', false);
|
||||
$this->assertDef('%', false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
27
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php
Executable file
27
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_TextDecorationTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function testCaseInsensitive()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_TextDecoration();
|
||||
|
||||
$this->assertDef('none');
|
||||
$this->assertDef('none underline', 'underline');
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/URITest.php
Executable file
29
htmlpurifier-4.10.0/tests/HTMLPurifier/AttrDef/CSS/URITest.php
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrDef_CSS_URITest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->def = new HTMLPurifier_AttrDef_CSS_URI();
|
||||
|
||||
$this->assertDef('', false);
|
||||
|
||||
// we could be nice but we won't be
|
||||
$this->assertDef('http://www.example.com/', false);
|
||||
|
||||
$this->assertDef('url(', false);
|
||||
$this->assertDef('url("")', true);
|
||||
$result = 'url("http://www.example.com/")';
|
||||
$this->assertDef('url(http://www.example.com/)', $result);
|
||||
$this->assertDef('url("http://www.example.com/")', $result);
|
||||
$this->assertDef("url('http://www.example.com/')", $result);
|
||||
$this->assertDef(
|
||||
' url( "http://www.example.com/" ) ', $result);
|
||||
$this->assertDef("url(http://www.example.com/foo,bar\)\'\()",
|
||||
'url("http://www.example.com/foo,bar%29%27%28")');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
Reference in New Issue
Block a user