DrupalBin
Submit Code
About
Recent Posts
float?
2 hours 25 min
ago
views handler
5 hours 55 min
ago
Code
6 hours 11 min
ago
Code
6 hours 12 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
CSS Filter
View
Download
Fix
July 22, 2008 - 4:19pm — Anonymous
function
filter_css
(
$css
,
$allowed_properties
=
array
(
'azimuth'
,
'background'
,
'background-color'
,
'background-image'
,
'background-repeat'
,
'background-attachment'
,
'background-position'
,
'border'
,
'border-top-width'
,
'border-right-width'
,
'border-bottom-width'
,
'border-left-width'
,
'border-width'
,
'border-top-color'
,
'border-right-color'
,
'border-bottom-color'
,
'border-left-color'
,
'border-color'
,
'border-top-style'
,
'border-right-style'
,
'border-bottom-style'
,
'border-left-style'
,
'border-style'
,
'border-top'
,
'border-right'
,
'border-bottom'
,
'border-left'
,
'clear'
,
'color'
,
'cursor'
,
'direction'
,
'display'
,
'elevation'
,
'float'
,
'font'
,
'font-family'
,
'font-size'
,
'font-style'
,
'font-variant'
,
'font-weight'
,
'height'
,
'letter-spacing'
,
'line-height'
,
'margin'
,
'margin-top'
,
'margin-right'
,
'margin-bottom'
,
'margin-left'
,
'overflow'
,
'padding'
,
'padding-top'
,
'padding-right'
,
'padding-bottom'
,
'padding-left'
,
'pause'
,
'pause-after'
,
'pause-before'
,
'pitch'
,
'pitch-range'
,
'richness'
,
'speak'
,
'speak-header'
,
'speak-numeral'
,
'speak-punctuation'
,
'speech-rate'
,
'stress'
,
'text-align'
,
'text-decoration'
,
'text-indent'
,
'unicode-bidi'
,
'vertical-align'
,
'voice-family'
,
'volume'
,
'white-space'
,
'width'
,
'fill'
,
'fill-opacity'
,
'fill-rule'
,
'stroke'
,
'stroke-width'
,
'stroke-linecap'
,
'stroke-linejoin'
,
'stroke-opacity'
,
)
,
$allowed_values
=
array
(
'auto'
,
'aqua'
,
'black'
,
'block'
,
'blue'
,
'bold'
,
'both'
,
'bottom'
,
'brown'
,
'center'
,
'collapse'
,
'dashed'
,
'dotted'
,
'fuchsia'
,
'gray'
,
'green'
,
'italic'
,
'left'
,
'lime'
,
'maroon'
,
'medium'
,
'none'
,
'navy'
,
'normal'
,
'nowrap'
,
'olive'
,
'pointer'
,
'purple'
,
'red'
,
'right'
,
'solid'
,
'silver'
,
'teal'
,
'top'
,
'transparent'
,
'underline'
,
'white'
,
'yellow'
,
)
,
$allowed_values_regex
=
'/(#[0-9a-f]+|rgb
\(
\d
+%?,
\d
*%?,?
\d
*%?
\)
?|
\d
{0,2}
\.
?
\d
{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|
\)
)?)/'
,
$disallowed_url_regex
=
'/url
\s
*
\(
\s
*[^
\s
)]+?
\s
*
\)
\s
*/'
)
{
foreach
(
$css
as
$statement_key
=>
$statement
)
{
foreach
(
$statement
[
'values'
]
as
$key
=>
$value
)
{
if
(
!
in_array
(
$key
,
$allowed_keys
)
)
{
unset
(
$css
[
$statement_key
]
)
;
continue
;
}
$value
=
str_replace
(
'!important'
,
$value
)
;
if
(
!
in_array
(
$value
,
$allowed_values
)
|| !
preg_match
(
$allowed_values_regex
,
$value
)
||
preg_match
(
$disallowed_url_regex
,
$value
)
)
{
unset
(
$css
[
$statement_key
]
)
;
continue
;
}
}
}
return
$css
;
}
css