Follow-up to feature #9625: Fixed regular expression
authorOliver Hader <oliver.hader@typo3.org>
Thu, 6 Nov 2008 18:45:08 +0000 (18:45 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 6 Nov 2008 18:45:08 +0000 (18:45 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4428 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_extmgm.php

index cb0ced7..3e072f4 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2008-11-07  Jeff Segars  <jeff@webempoweredchurch.org>
+2008-11-06  Oliver Hader  <oliver@typo3.org>
+
+       * Follow-up to feature #9625: Fixed regular expression
+
+2008-11-06  Jeff Segars  <jeff@webempoweredchurch.org>
 
        * Added feature #9615: Move frontend editing to a system extension.
 
index 0d52da5..f5399ae 100644 (file)
@@ -410,12 +410,17 @@ final class t3lib_extMgm {
         * Compares an existing list of items and a list of items to be inserted
         * and returns a duplicate-free variant of that insertion list.
         *
+        * Example:
+        *  + list: 'field_a, field_b;;;;2-2-2, field_c;;;;3-3-3'
+        *  + insertion: 'field_b, field_d, field_c;;;4-4-4'
+        * -> new insertion: 'field_d'
+        *
         * @param       string          $list: The list of items to be extended
         * @param       string          $insertionList: The list of items to inserted
         * @return      string          Duplicate-free list of items to be inserted
         */
        protected static function removeDuplicatesForInsertion($list, $insertionList) {
-               $pattern = '/(^|,)\s*([^,]+)\b[^,]*(,|$)/';
+               $pattern = '/(^|,)\s*\b([^;,]+)\b[^,]*/';
 
                if ($list && preg_match_all($pattern, $list, $listMatches)) {
                        if ($insertionList && preg_match_all($pattern, $insertionList, $insertionListMatches)) {
@@ -425,7 +430,7 @@ final class t3lib_extMgm {
                                                $duplicate = preg_quote($duplicate, '/');
                                        }
                                        $insertionList = preg_replace(
-                                               array('/(^|,)\s*(' . implode('|', $duplicates) . ')\b[^,]*(,|$)/', ',$'),
+                                               array('/(^|,)\s*\b(' . implode('|', $duplicates) . ')\b[^,]*(,|$)/', '/,$/'),
                                                array('\3', ''),
                                                $insertionList
                                        );