PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Services/SmartCodeParser.php +22 -1 2.4.012.10.0 View file →
@@ -51,16 +51,37 @@
51 51 }
52 52
53 53 public function parseShortcode($string)
54 54 {
55 - // check if the string contains any smartcode
56 55 if (strpos($string, '{{') === false && strpos($string, '##') === false) {
57 56 return $string;
58 57 }
59 58
59 + if (static::$isHtml) {
60 + $string = $this->resolveHrefPlaceholders($string);
61 + }
62 +
60 63 return preg_replace_callback('/({{|##)+(.*?)(}}|##)/', function ($matches) {
61 64 return $this->replace($matches);
62 65 }, $string);
66 + }
67 +
68 + /**
69 + * Resolve placeholders inside href="..." attributes to raw URLs.
70 + * Prevents nested anchors when URL smartcodes auto-wrap in HTML mode.
71 + */
72 + protected function resolveHrefPlaceholders($string)
73 + {
74 + return preg_replace_callback(
75 + '/(?<![a-zA-Z-])href\s*=\s*(["\'])([^"\']*(?:\{\{|##)[^"\']*)\1/i',
76 + function ($m) {
77 + static::$isHtml = false;
78 + $resolved = $this->parseShortcode($m[2]);
79 + static::$isHtml = true;
80 + return 'href=' . $m[1] . esc_url($resolved) . $m[1];
81 + },
82 + $string
83 + );
63 84 }
64 85
65 86 protected function replace($matches)
66 87 {