MDL-32081 csslib: Improved handling of parentheses when processing styles
authorSam Hemelryk <sam@moodle.com>
Mon, 26 Mar 2012 23:34:31 +0000 (12:34 +1300)
committerSam Hemelryk <sam@moodle.com>
Thu, 29 Mar 2012 21:20:59 +0000 (10:20 +1300)
lib/csslib.php

index 03d728c..5fc0f9b 100644 (file)
@@ -638,6 +638,13 @@ class css_optimiser {
                     }
                     switch ($char) {
                         case ';':
+                            if ($inparenthesis) {
+                                $buffer .= $char;
+                                // continue 1: The switch processing chars
+                                // continue 2: The switch processing the state
+                                // continue 3: The for loop
+                                continue 3;
+                            }
                             $currentrule->add_style($buffer);
                             $buffer = '';
                             $inquotes = false;
@@ -656,6 +663,21 @@ class css_optimiser {
                             $this->rawrules++;
                             $buffer = '';
                             $inquotes = false;
+                            $inparenthesis = false;
+                            // continue 1: The switch processing chars
+                            // continue 2: The switch processing the state
+                            // continue 3: The for loop
+                            continue 3;
+                        case '(':
+                            $inparenthesis = true;
+                            $buffer .= $char;
+                            // continue 1: The switch processing chars
+                            // continue 2: The switch processing the state
+                            // continue 3: The for loop
+                            continue 3;
+                        case ')':
+                            $inparenthesis = false;
+                            $buffer .= $char;
                             // continue 1: The switch processing chars
                             // continue 2: The switch processing the state
                             // continue 3: The for loop