Prevent BBCodes being overwritten through 3rd party packages
authorAlexander Ebert <ebert@woltlab.com>
Wed, 18 Dec 2013 00:17:56 +0000 (01:17 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 18 Dec 2013 00:17:56 +0000 (01:17 +0100)
wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php

index 9c18d0b191ef7015f098d80820e30097d1a92f14..f0bd41252e9b288777852968ccb707ba1b6f78f0 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\package\plugin;
 use wcf\data\bbcode\attribute\BBCodeAttributeEditor;
+use wcf\data\package\PackageCache;
 use wcf\system\exception\SystemException;
 use wcf\system\WCF;
 
@@ -107,6 +108,16 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                if ($data['bbcodeTag'] == 'all' || $data['bbcodeTag'] == 'none') {
                        throw new SystemException("BBCodes can't be called 'all' or 'none'");
                }
+               
+               // check if bbcode tag already exists
+               $sqlData = $this->findExistingItem($data);
+               $statement = WCF::getDB()->prepareStatement($sqlData['sql']);
+               $statement->execute($sqlData['parameters']);
+               $row = $statement->fetchArray();
+               if ($row && $row['packageID'] != $this->installation->getPackageID()) {
+                       $package = PackageCache::getInstance()->getPackage($row['packageID']);
+                       throw new SystemException("BBCode '" . $data['bbcodeTag'] . "' is already provided by '" . $package . "' ('" . $package->package . "').");
+               }
        }
        
        /**