Просмотр исходного кода

Ticket #3998 - Incorrect metatags/labels.

AntonLV 4 лет назад
Родитель
Сommit
b6b61e42c8

+ 3 - 2
inc/classes/BxDolMetatags.php

@@ -400,8 +400,9 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
             $f = function ($a) use ($sKeyword, $iId) {
                 return $a[1] . '<a class="bx-tag" rel="tag" href="' . $this->keywordsGetHashTagUrl($sKeyword, $iId) . '"><s>#</s><b>' . $sKeyword . '</b></a>';
             };
-            $s = preg_replace_callback('/([^\pN^\pL])\#(' . preg_quote($sKeyword) . ')/u', $f, $s);
-            $s = preg_replace_callback('/^()\#(' . preg_quote($sKeyword) . ')/u', $f, $s);
+
+            $s = preg_replace_callback('/([^\pN^\pL])\#(' . preg_quote($sKeyword, '/') . ')/u', $f, $s);
+            $s = preg_replace_callback('/^()\#(' . preg_quote($sKeyword, '/') . ')/u', $f, $s);
         }
 
         return $s;

+ 10 - 2
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -2895,8 +2895,12 @@ class BxBaseModGeneralModule extends BxDolModule
         if($oMetatags->keywordsIsEnabled() && !empty($CNF[$sKey]) && !empty($aContentInfo[$CNF[$sKey]])) {
             $aLabels = unserialize($aContentInfo[$CNF[$sKey]]);
             if(!empty($aLabels) && is_array($aLabels))
-                foreach ($aLabels as $sLabel)
+                foreach ($aLabels as $sLabel) {
+                    if(!preg_match("/(\pL[\pL\pN_]+)/u", $sLabel)) 
+                        continue;
+
                     $oMetatags->keywordsAddOne($iContentId, $sLabel, false);
+                }
         }
         
         return true;
@@ -2931,8 +2935,12 @@ class BxBaseModGeneralModule extends BxDolModule
         if($oMetatags->keywordsIsEnabled() && !empty($CNF[$sKey]) && !empty($aContentInfo[$CNF[$sKey]])) {
             $aLabels = unserialize($aContentInfo[$CNF[$sKey]]);
             if(!empty($aLabels) && is_array($aLabels))
-                foreach ($aLabels as $sLabel)
+                foreach ($aLabels as $sLabel) {
+                    if(!preg_match("/(\pL[\pL\pN_]+)/u", $sLabel))
+                        continue;
+
                     $oMetatags->keywordsAddOne($iContentId, $sLabel, false);
+                }
         }
 
         return true;

+ 7 - 4
studio/template/scripts/BxBaseStudioFormsLabels.php

@@ -12,15 +12,18 @@ bx_import('BxTemplStudioFormView');
 
 class BxStudioFormsLabelsCheckerHelper extends BxDolFormCheckerHelper
 {
-    public function checkAvailUnique($s, $aExclude = array())
+    public function checkAvailUnique($s, $aExclude = [])
     {
-        $aLabel = BxDolLabel::getInstance()->getLabels(array(
+        if(!preg_match("/(\pL[\pL\pN_]+)/u", $s))
+            return false;
+
+        $aLabel = BxDolLabel::getInstance()->getLabels([
             'type' => 'value', 
             'value' => $s
-        ));
+        ]);
 
         if(!is_array($aExclude))
-            $aExclude = array($aExclude);
+            $aExclude = [$aExclude];
 
         return empty($aLabel) || !is_array($aLabel) || in_array($aLabel['id'], $aExclude);
     }