Fixed overridden variables being persistent
authorAlexander Ebert <ebert@woltlab.com>
Sat, 10 Aug 2013 12:20:54 +0000 (14:20 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 10 Aug 2013 12:20:54 +0000 (14:20 +0200)
Fixes #1450

wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/system/style/StyleCompiler.class.php

index d5614cc740ca56608f6c151f2e2dfa85d3d88390..b2043d1a41331258289ea7919689c34509bf88a0 100644 (file)
@@ -332,9 +332,6 @@ class StyleAddForm extends AbstractForm {
                                                'text' => $matches[1]
                                        );
                                }
-                               else {
-                                       $this->variables[$matches[1]] = $matches[2];
-                               }
                        }
                        else {
                                // not valid
index fa5c052a639716dfc717bb45905fcda4ea3b380f..25d19ac05d9c91a6be081c0ff90e235bf34c4b1e 100644 (file)
@@ -7,6 +7,7 @@ use wcf\system\Callback;
 use wcf\system\SingletonFactory;
 use wcf\system\WCF;
 use wcf\util\FileUtil;
+use wcf\util\StringUtil;
 use wcf\util\StyleUtil;
 
 /**
@@ -65,6 +66,17 @@ class StyleCompiler extends SingletonFactory {
                        unset($variables['individualLess']);
                }
                
+               // apply overrides
+               if (isset($variables['overrideLess'])) {
+                       $lines = explode("\n", StringUtil::unifyNewlines($variables['overrideLess']));
+                       foreach ($lines as $line) {
+                               if (preg_match('~^@([a-zA-Z]+): ?([@a-zA-Z0-9 ,\.\(\)\%\#-]+);$~', $line, $matches)) {
+                                       $variables[$matches[1]] = $matches[2];
+                               }
+                       }
+                       unset($variables['overrideLess']);
+               }
+               
                $this->compileStylesheet(
                        WCF_DIR.'style/style-'.$style->styleID,
                        $files,