Skip to content

Commit

Permalink
-Only identifier attributes may have their surrounding quotes removed
Browse files Browse the repository at this point in the history
  • Loading branch information
codenothing committed Aug 3, 2011
1 parent f1ad86c commit 9168794
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/lib/Cleanup.php
Expand Up @@ -143,7 +143,10 @@ public function removeInjections( $css ) {
$pos = 0;
while ( preg_match( $this->rtoken, $css, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
$value = $match[ 2 ][ 0 ];
if ( preg_match( $this->rspace, $value ) ) {
$id = substr( $css, $match[ 0 ][ 1 ] - 4, 4 ) == '[id=' ? true : false;
$class = substr( $css, $match[ 0 ][ 1 ] - 7, 7 ) == '[class=' ? true : false;

if ( preg_match( $this->rspace, $value ) || ( ! $id && ! $class ) ) {
$quote = preg_match( $this->rquote, $value ) ? "\"" : "'";
$value = "$quote$value$quote";
$css = substr_replace( $css, $value, $match[ 0 ][ 1 ], strlen( $match[ 0 ][ 0 ] ) );
Expand Down
2 changes: 1 addition & 1 deletion unit/sheets/expected/empty-selector.css
@@ -1 +1 @@
a[href$=/test/] span:first-child{b:1}
a[href$='/test/'] span:first-child{b:1}
2 changes: 1 addition & 1 deletion unit/sheets/expected/pit.css
Expand Up @@ -17,7 +17,7 @@
}
}

body > div[title='spacing test\'s'] + a[href$=nospace] :first-child {
body > div[title='spacing test\'s'] + a[href$='nospace'] :first-child {
color: #000;
background: #fff url(http://www.example.com/body-bg.png?a=semi;);
margin: 0 auto;
Expand Down

0 comments on commit 9168794

Please sign in to comment.