Fixed style editing
authorAlexander Ebert <ebert@woltlab.com>
Mon, 23 Jan 2017 08:44:13 +0000 (09:44 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 23 Jan 2017 08:44:13 +0000 (09:44 +0100)
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php

index d49fd672af38e00c44948595233307d11bf175d2..a3e762c064318a6b3c666315462761d18a4fb8c4 100644 (file)
@@ -303,10 +303,7 @@ class StyleAddForm extends AbstractForm {
                                throw new UserInputException('packageName', 'invalid');
                        }
                        
-                       // 3rd party styles may never have com.woltlab.* as name
-                       if (strpos($this->packageName, 'com.woltlab.') === 0) {
-                               throw new UserInputException('packageName', 'reserved');
-                       }
+                       $this->enforcePackageNameRestriction();
                }
                
                // validate template group id
@@ -329,6 +326,18 @@ class StyleAddForm extends AbstractForm {
                }
        }
        
+       /**
+        * Disallow the use of `com.woltlab.*` for package names to avoid accidential collisions.
+        * 
+        * @throws      UserInputException
+        */
+       protected function enforcePackageNameRestriction() {
+               // 3rd party styles may never have com.woltlab.* as name
+               if (strpos($this->packageName, 'com.woltlab.') !== false) {
+                       throw new UserInputException('packageName', 'reserved');
+               }
+       }
+       
        /**
         * Validates LESS-variable overrides.
         * 
index c27d53a7745eee7f81d27ab825106e5e31e1ae57..1b1d6444701ff7fd89f73335e0e09350680f4ff5 100644 (file)
@@ -57,6 +57,15 @@ class StyleEditForm extends StyleAddForm {
                }
        }
        
+       /**
+        * @inheritDoc
+        */
+       protected function enforcePackageNameRestriction() {
+               if ($this->style->isTainted) {
+                       parent::enforcePackageNameRestriction();
+               }
+       }
+       
        /**
         * @inheritDoc
         */