From: Tim Düsterhus Date: Sun, 24 Feb 2019 15:47:14 +0000 (+0100) Subject: Split tags at comma in TagEngine::addObjectTags() X-Git-Tag: 3.0.21~18 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=32775cf9c5a2d2ce3ea166a18bddd57ff5d6c0e2;p=GitHub%2FWoltLab%2FWCF.git Split tags at comma in TagEngine::addObjectTags() On Android detecting key codes is unreliable, which causes the tag[] field to contain values with a comma. This adds the missing server side “validation” that the tags actually cannot contain commas by splitting them. --- diff --git a/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php b/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php index 49c95436e2..ade3910f98 100644 --- a/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php +++ b/wcfsetup/install/files/lib/system/tagging/TagEngine.class.php @@ -7,6 +7,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\InvalidObjectTypeException; use wcf\system\SingletonFactory; use wcf\system\WCF; +use wcf\util\ArrayUtil; /** * Manages the tagging of objects. @@ -28,7 +29,9 @@ class TagEngine extends SingletonFactory { */ public function addObjectTags($objectType, $objectID, array $tags, $languageID, $replace = true) { $objectTypeID = $this->getObjectTypeID($objectType); - $tags = array_unique($tags); + $tags = array_unique(array_reduce(ArrayUtil::trim(array_map(function($tag) { + return explode(',', $tag); + }, $tags)), 'array_merge', [])); // remove tags prior to apply the new ones (prevents duplicate entries) if ($replace) {