2006-08-12 20:22:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-02-25 21:58:17 +00:00
|
|
|
function setup() {
|
|
|
|
parent::setup();
|
2006-08-12 20:22:09 +00:00
|
|
|
$this->def = new HTMLPurifier_AttrDef_CSS();
|
2008-02-25 21:58:17 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-02-25 21:58:17 +00:00
|
|
|
function test() {
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// regular cases, singular
|
2006-08-12 20:22:09 +00:00
|
|
|
$this->assertDef('text-align:right;');
|
2006-08-13 19:08:14 +00:00
|
|
|
$this->assertDef('border-left-style:solid;');
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->assertDef('border-style:solid dotted;');
|
2006-08-13 16:52:31 +00:00
|
|
|
$this->assertDef('clear:right;');
|
|
|
|
$this->assertDef('float:left;');
|
|
|
|
$this->assertDef('font-style:italic;');
|
|
|
|
$this->assertDef('font-variant:small-caps;');
|
|
|
|
$this->assertDef('font-weight:bold;');
|
|
|
|
$this->assertDef('list-style-position:outside;');
|
|
|
|
$this->assertDef('list-style-type:upper-roman;');
|
2006-08-29 02:01:58 +00:00
|
|
|
$this->assertDef('list-style:upper-roman inside;');
|
2006-08-13 16:52:31 +00:00
|
|
|
$this->assertDef('text-transform:capitalize;');
|
2006-08-13 21:23:57 +00:00
|
|
|
$this->assertDef('background-color:rgb(0,0,255);');
|
|
|
|
$this->assertDef('background-color:transparent;');
|
2010-05-21 15:53:52 +00:00
|
|
|
$this->assertDef('background:#333 url("chess.png") repeat fixed 50% top;');
|
2006-08-13 21:23:57 +00:00
|
|
|
$this->assertDef('color:#F00;');
|
|
|
|
$this->assertDef('border-top-color:#F00;');
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->assertDef('border-color:#F00 #FF0;');
|
2006-08-13 23:08:38 +00:00
|
|
|
$this->assertDef('border-top-width:thin;');
|
|
|
|
$this->assertDef('border-top-width:12px;');
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->assertDef('border-width:5px 1px 4px 2px;');
|
2006-08-13 23:08:38 +00:00
|
|
|
$this->assertDef('border-top-width:-12px;', false);
|
|
|
|
$this->assertDef('letter-spacing:normal;');
|
|
|
|
$this->assertDef('letter-spacing:2px;');
|
|
|
|
$this->assertDef('word-spacing:normal;');
|
|
|
|
$this->assertDef('word-spacing:3em;');
|
2006-08-14 02:08:45 +00:00
|
|
|
$this->assertDef('font-size:200%;');
|
|
|
|
$this->assertDef('font-size:larger;');
|
|
|
|
$this->assertDef('font-size:12pt;');
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->assertDef('line-height:2;');
|
|
|
|
$this->assertDef('line-height:2em;');
|
|
|
|
$this->assertDef('line-height:20%;');
|
|
|
|
$this->assertDef('line-height:normal;');
|
|
|
|
$this->assertDef('line-height:-20%;', false);
|
|
|
|
$this->assertDef('margin-left:5px;');
|
|
|
|
$this->assertDef('margin-right:20%;');
|
|
|
|
$this->assertDef('margin-top:auto;');
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->assertDef('margin:auto 5%;');
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->assertDef('padding-bottom:5px;');
|
|
|
|
$this->assertDef('padding-top:20%;');
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->assertDef('padding:20% 10%;');
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->assertDef('padding-top:-20%;', false);
|
|
|
|
$this->assertDef('text-indent:3em;');
|
|
|
|
$this->assertDef('text-indent:5%;');
|
|
|
|
$this->assertDef('text-indent:-3em;');
|
|
|
|
$this->assertDef('width:50%;');
|
|
|
|
$this->assertDef('width:50px;');
|
|
|
|
$this->assertDef('width:auto;');
|
|
|
|
$this->assertDef('width:-50px;', false);
|
2006-08-16 15:12:48 +00:00
|
|
|
$this->assertDef('text-decoration:underline;');
|
2006-08-16 17:25:25 +00:00
|
|
|
$this->assertDef('font-family:sans-serif;');
|
2010-05-21 15:53:52 +00:00
|
|
|
$this->assertDef('font-family:Gill, "Times New Roman", sans-serif;');
|
2006-08-27 00:49:34 +00:00
|
|
|
$this->assertDef('font:12px serif;');
|
|
|
|
$this->assertDef('border:1px solid #000;');
|
|
|
|
$this->assertDef('border-bottom:2em double #FF00FA;');
|
2006-08-27 01:45:23 +00:00
|
|
|
$this->assertDef('border-collapse:collapse;');
|
2007-08-11 06:52:26 +00:00
|
|
|
$this->assertDef('border-collapse:separate;');
|
2006-08-27 01:45:23 +00:00
|
|
|
$this->assertDef('caption-side:top;');
|
|
|
|
$this->assertDef('vertical-align:middle;');
|
|
|
|
$this->assertDef('vertical-align:12px;');
|
|
|
|
$this->assertDef('vertical-align:50%;');
|
|
|
|
$this->assertDef('table-layout:fixed;');
|
2010-05-21 15:53:52 +00:00
|
|
|
$this->assertDef('list-style-image:url("nice.jpg");');
|
|
|
|
$this->assertDef('list-style:disc url("nice.jpg") inside;');
|
|
|
|
$this->assertDef('background-image:url("foo.jpg");');
|
2007-01-15 01:14:24 +00:00
|
|
|
$this->assertDef('background-image:none;');
|
|
|
|
$this->assertDef('background-repeat:repeat-y;');
|
|
|
|
$this->assertDef('background-attachment:fixed;');
|
2007-01-20 01:40:56 +00:00
|
|
|
$this->assertDef('background-position:left 90%;');
|
2007-09-03 15:16:33 +00:00
|
|
|
$this->assertDef('border-spacing:1em;');
|
|
|
|
$this->assertDef('border-spacing:1em 2em;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// duplicates
|
2006-08-13 17:05:30 +00:00
|
|
|
$this->assertDef('text-align:right;text-align:left;',
|
|
|
|
'text-align:left;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// a few composites
|
|
|
|
$this->assertDef('font-variant:small-caps;font-weight:900;');
|
|
|
|
$this->assertDef('float:right;text-align:right;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// selective removal
|
2006-08-13 17:05:30 +00:00
|
|
|
$this->assertDef('text-transform:capitalize;destroy:it;',
|
|
|
|
'text-transform:capitalize;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// inherit works for everything
|
|
|
|
$this->assertDef('text-align:inherit;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// bad props
|
|
|
|
$this->assertDef('nodice:foobar;', false);
|
|
|
|
$this->assertDef('position:absolute;', false);
|
2010-04-26 16:06:06 +00:00
|
|
|
$this->assertDef('background-image:url(\'javascript:alert\(\)\');', false);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-09-04 23:01:47 +00:00
|
|
|
// airy input
|
|
|
|
$this->assertDef(' font-weight : bold; color : #ff0000',
|
|
|
|
'font-weight:bold;color:#ff0000;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-01 17:00:55 +00:00
|
|
|
// case-insensitivity
|
|
|
|
$this->assertDef('FLOAT:LEFT;', 'float:left;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-02-25 21:58:17 +00:00
|
|
|
// !important stripping
|
|
|
|
$this->assertDef('float:left !important;', 'float:left;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-12 20:22:09 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
function testProprietary() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('CSS.Proprietary', true);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
$this->assertDef('scrollbar-arrow-color:#ff0;');
|
|
|
|
$this->assertDef('scrollbar-base-color:#ff6347;');
|
|
|
|
$this->assertDef('scrollbar-darkshadow-color:#ffa500;');
|
|
|
|
$this->assertDef('scrollbar-face-color:#008080;');
|
|
|
|
$this->assertDef('scrollbar-highlight-color:#ff69b4;');
|
|
|
|
$this->assertDef('scrollbar-shadow-color:#f0f;');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
$this->assertDef('opacity:.2;');
|
|
|
|
$this->assertDef('-moz-opacity:.2;');
|
|
|
|
$this->assertDef('-khtml-opacity:.2;');
|
|
|
|
$this->assertDef('filter:alpha(opacity=20);');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-02-25 21:58:17 +00:00
|
|
|
function testImportant() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('CSS.AllowImportant', true);
|
2008-02-25 21:58:17 +00:00
|
|
|
$this->assertDef('float:left !important;');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-02-25 22:05:49 +00:00
|
|
|
function testTricky() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('CSS.AllowTricky', true);
|
2008-02-25 22:05:49 +00:00
|
|
|
$this->assertDef('display:none;');
|
|
|
|
$this->assertDef('visibility:visible;');
|
2008-11-27 21:14:50 +00:00
|
|
|
$this->assertDef('overflow:scroll;');
|
2008-02-25 22:05:49 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-12 20:22:09 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|