From 6147a6661c52e839f726ce16b8ac5bbbba9e206c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 23 Jan 2017 09:44:13 +0100 Subject: [PATCH] Fixed style editing --- .../files/lib/acp/form/StyleAddForm.class.php | 17 +++++++++++++---- .../files/lib/acp/form/StyleEditForm.class.php | 9 +++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index d49fd672af..a3e762c064 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php index c27d53a774..1b1d644470 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php @@ -57,6 +57,15 @@ class StyleEditForm extends StyleAddForm { } } + /** + * @inheritDoc + */ + protected function enforcePackageNameRestriction() { + if ($this->style->isTainted) { + parent::enforcePackageNameRestriction(); + } + } + /** * @inheritDoc */ -- 2.20.1