Fixed Handling of links with empty link text (e.g. [URL=https://www.google.com/][/URL])

Steffen

Well-known member
Affected version
2.0.7
Consider the following BB Code: [URL='https://www.google.com/'][/URL]

It is syntactically valid but obviously the link title is empty/missing. Two observations:

1) When using the plaintext editor, you can submit such a link just fine and XenForo will render an invisible link. I think it's impossible to prevent someone from intentionally submitting an invisible link (Hello Unicode!) but the cases I observed seemed like unintentional blunders.

2) Switching from the plaintext editor to the WYSIWYG editor and back causes the link to vanish.

What do you think about using the URL as the title if the title is empty?

Diff:
diff --git a/src/XF/BbCode/Renderer/Html.php b/src/XF/BbCode/Renderer/Html.php
index 7775f4ece..bf58f30fc 100644
--- a/src/XF/BbCode/Renderer/Html.php
+++ b/src/XF/BbCode/Renderer/Html.php
@@ -925,6 +925,11 @@ class Html extends AbstractRenderer
         {
             $url = $option;
             $text = $this->renderSubTree($children, $options);
+
+            if ($text === '')
+            {
+                $text = $url;
+            }
         }
         else
         {
 
Top Bottom