PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.23
ووسلام – همگام سازی ووکامرس و باسلام v1.10.23
1.10.23 1.10.22 1.10.21 1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 All 56 releases
← All changes | includes/Services/Products/DescriptionErrorSanitizer.php +26 -1 1.10.2 → 1.10.23 View file →
@@ -56,9 +56,19 @@
56 56 if (is_string($snippet) && $snippet !== '') {
57 57 if (preg_match_all('/<em>(.*?)<\/em>/isu', $snippet, $matches)) {
58 58 foreach ($matches[1] as $match) {
59 59 $value = trim(wp_strip_all_tags(html_entity_decode($match, ENT_QUOTES | ENT_HTML5, 'UTF-8')));
60 - if ($value !== '') $found[] = $value;
60 + if ($value === '') continue;
61 +
62 + $found[] = $value;
63 +
64 + // Basalam highlights a whole window of text and returns it normalized
65 + // (e.g. "یک" comes back as "1"), so the full phrase often matches nothing
66 + // in the original description. The part that actually triggers the
67 + // "social id" signal is the handle-like token, so target it separately.
68 + foreach (self::handleLikeTokens($value) as $token) {
69 + $found[] = $token;
70 + }
61 71 }
62 72 }
63 73 }
64 74
@@ -68,8 +78,23 @@
68 78 if ($value !== '') $found[] = $value;
69 79 }
70 80
71 81 return $found;
82 + }
83 +
84 + /**
85 + * Pulls out handle/domain-like tokens ("s.exy", "س.کسی", "insta.gram") from a
86 + * highlighted snippet.
87 + *
88 + * @return string[]
89 + */
90 + private static function handleLikeTokens(string $text): array
91 + {
92 + if (!preg_match_all('/[\p{L}\p{N}_]+(?:\.[\p{L}\p{N}_]+)+/u', $text, $matches)) return [];
93 +
94 + return array_values(array_filter($matches[0], static function ($token) {
95 + return mb_strlen($token) >= 3;
96 + }));
72 97 }
73 98
74 99 public static function sanitize(string $description, array $values): string
75 100 {