1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

Remove trailing whitespace.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-12-06 02:28:20 -05:00
parent 3a6b63dff1
commit 2c955af135
476 changed files with 5595 additions and 5547 deletions

View File

@@ -2,26 +2,26 @@
class HTMLPurifier_AttrDef_CSS_AlphaValueTest extends HTMLPurifier_AttrDefHarness
{
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);
}
}

View File

@@ -2,11 +2,11 @@
class HTMLPurifier_AttrDef_CSS_BackgroundPositionTest extends HTMLPurifier_AttrDefHarness
{
function test() {
$this->def = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
// explicitly cited in spec
$this->assertDef('0% 0%');
$this->assertDef('100% 100%');
@@ -25,7 +25,7 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPositionTest extends HTMLPurifier_AttrD
$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', 'center top');
@@ -36,32 +36,32 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPositionTest extends HTMLPurifier_AttrD
$this->assertDef('bottom left', 'left bottom');
$this->assertDef('bottom center', '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%');
}
}

View File

@@ -2,12 +2,12 @@
class HTMLPurifier_AttrDef_CSS_BackgroundTest extends HTMLPurifier_AttrDefHarness
{
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);
@@ -15,8 +15,8 @@ class HTMLPurifier_AttrDef_CSS_BackgroundTest extends HTMLPurifier_AttrDefHarnes
'rgb(34, 56, 33) url(chess.png) repeat fixed top',
'rgb(34,56,33) url(chess.png) repeat fixed top'
);
}
}

View File

@@ -2,19 +2,19 @@
class HTMLPurifier_AttrDef_CSS_BorderTest extends HTMLPurifier_AttrDefHarness
{
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)');
}
}

View File

@@ -2,11 +2,11 @@
class HTMLPurifier_AttrDef_CSS_ColorTest extends HTMLPurifier_AttrDefHarness
{
function test() {
$this->def = new HTMLPurifier_AttrDef_CSS_Color();
$this->assertDef('#F00');
$this->assertDef('#fff');
$this->assertDef('#eeeeee');
@@ -14,27 +14,27 @@ class HTMLPurifier_AttrDef_CSS_ColorTest extends HTMLPurifier_AttrDefHarness
$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('#G00', false);
$this->assertDef('cmyk(40, 23, 43, 23)', false);
$this->assertDef('rgb(0%, 23, 68%)', false);
// 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
}
}

View File

@@ -3,29 +3,29 @@
class HTMLPurifier_AttrDef_CSS_Composite_Testable extends
HTMLPurifier_AttrDef_CSS_Composite
{
// we need to pass by ref to get the mocks in
function HTMLPurifier_AttrDef_CSS_Composite_Testable(&$defs) {
$this->defs =& $defs;
}
}
class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness
{
protected $def1, $def2;
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);
@@ -36,12 +36,12 @@ class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness
$def1->expectOnce('validate', $def1_params);
$def1->setReturnValue('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);
@@ -53,12 +53,12 @@ class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness
$def1->setReturnValue('validate', false, $def_params);
$def2->expectOnce('validate', $def_params);
$def2->setReturnValue('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);
@@ -70,11 +70,11 @@ class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness
$def1->setReturnValue('validate', false, $def_params);
$def2->expectOnce('validate', $def_params);
$def2->setReturnValue('validate', false, $def_params);
$result = $def->validate($input, $config, $context);
$this->assertIdentical($output, $result);
}
}

View File

@@ -2,27 +2,27 @@
class HTMLPurifier_AttrDef_CSS_FilterTest extends HTMLPurifier_AttrDefHarness
{
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);
}
}

View File

@@ -2,11 +2,11 @@
class HTMLPurifier_AttrDef_CSS_FontFamilyTest extends HTMLPurifier_AttrDefHarness
{
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'");
@@ -33,6 +33,6 @@ class HTMLPurifier_AttrDef_CSS_FontFamilyTest extends HTMLPurifier_AttrDefHarnes
$this->assertDef("'\\00045 a'", "'E a'");
$this->assertDef("'\\\nf'", "f");
}
}

View File

@@ -2,12 +2,12 @@
class HTMLPurifier_AttrDef_CSS_FontTest extends HTMLPurifier_AttrDefHarness
{
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');
@@ -17,17 +17,17 @@ class HTMLPurifier_AttrDef_CSS_FontTest extends HTMLPurifier_AttrDefHarness
$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);
}
}

View File

@@ -2,47 +2,47 @@
class HTMLPurifier_AttrDef_CSS_ImportantDecoratorTest extends HTMLPurifier_AttrDefHarness
{
/** Mock AttrDef decorator is wrapping */
protected $mock;
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->setReturnValue('validate', $output);
}
function testImportant() {
$this->setMock('23');
$this->assertDef('23 !important');
}
function testImportantInternalDefChanged() {
$this->setMock('23', '24');
$this->assertDef('23 !important', '24 !important');
}
function testImportantWithSpace() {
$this->setMock('23');
$this->assertDef('23 ! important ', '23 !important');
}
function testFakeImportant() {
$this->setMock('! foo important');
$this->assertDef('! foo important');
}
function testStrip() {
$this->def = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($this->mock, false);
$this->setMock('23');
$this->assertDef('23 ! important ', '23');
}
}

View File

@@ -2,11 +2,11 @@
class HTMLPurifier_AttrDef_CSS_LengthTest extends HTMLPurifier_AttrDefHarness
{
function test() {
$this->def = new HTMLPurifier_AttrDef_CSS_Length();
$this->assertDef('0');
$this->assertDef('0px');
$this->assertDef('4.5px');
@@ -18,23 +18,23 @@ class HTMLPurifier_AttrDef_CSS_LengthTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('3mm');
$this->assertDef('3pt');
$this->assertDef('3pc');
$this->assertDef('3PX', '3px');
$this->assertDef('3', false);
$this->assertDef('3miles', false);
}
function testNonNegative() {
$this->def = new HTMLPurifier_AttrDef_CSS_Length('0');
$this->assertDef('3cm');
$this->assertDef('-3mm', false);
}
function testBounding() {
$this->def = new HTMLPurifier_AttrDef_CSS_Length('-1in', '1in');
$this->assertDef('1cm');
@@ -42,6 +42,6 @@ class HTMLPurifier_AttrDef_CSS_LengthTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('0');
$this->assertDef('1em', false);
}
}

View File

@@ -2,12 +2,12 @@
class HTMLPurifier_AttrDef_CSS_ListStyleTest extends HTMLPurifier_AttrDefHarness
{
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');
@@ -15,10 +15,10 @@ class HTMLPurifier_AttrDef_CSS_ListStyleTest extends HTMLPurifier_AttrDefHarness
$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');
@@ -26,9 +26,9 @@ class HTMLPurifier_AttrDef_CSS_ListStyleTest extends HTMLPurifier_AttrDefHarness
// cases, so we're going off the W3C CSS validator
$this->assertDef('disc none', 'disc');
$this->assertDef('none disc', 'none');
}
}

View File

@@ -3,25 +3,25 @@
// borrowed for the sakes of this test
class HTMLPurifier_AttrDef_CSS_MultipleTest extends HTMLPurifier_AttrDefHarness
{
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');
}
}

View File

@@ -2,11 +2,11 @@
class HTMLPurifier_AttrDef_CSS_NumberTest extends HTMLPurifier_AttrDefHarness
{
function test() {
$this->def = new HTMLPurifier_AttrDef_CSS_Number();
$this->assertDef('0');
$this->assertDef('0.0', '0');
$this->assertDef('1.0', '1');
@@ -15,36 +15,36 @@ class HTMLPurifier_AttrDef_CSS_NumberTest extends HTMLPurifier_AttrDefHarness
$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);
}
function testNonNegative() {
$this->def = new HTMLPurifier_AttrDef_CSS_Number(true);
$this->assertDef('23');
$this->assertDef('-12', false);
}
}

View File

@@ -2,22 +2,22 @@
class HTMLPurifier_AttrDef_CSS_PercentageTest extends HTMLPurifier_AttrDefHarness
{
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);
}
}

View File

@@ -2,25 +2,25 @@
class HTMLPurifier_AttrDef_CSS_TextDecorationTest extends HTMLPurifier_AttrDefHarness
{
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);
}
}

View File

@@ -2,16 +2,16 @@
class HTMLPurifier_AttrDef_CSS_URITest extends HTMLPurifier_AttrDefHarness
{
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);
// no quotes are used, since that's the most widely supported
// syntax
$this->assertDef('url(', false);
@@ -22,11 +22,11 @@ class HTMLPurifier_AttrDef_CSS_URITest extends HTMLPurifier_AttrDefHarness
$this->assertDef("url('http://www.example.com/')", $result);
$this->assertDef(
' url( "http://www.example.com/" ) ', $result);
// escaping
$this->assertDef("url(http://www.example.com/foo,bar\))",
$this->assertDef("url(http://www.example.com/foo,bar\))",
"url(http://www.example.com/foo\,bar\))");
}
}