URL Tag Parser/Formatter?

Mr. Goodie2Shoes

Well-known member
Hello, I am just checking out some stuff and found that if I manipulate [url]http://something.com[/url] I can change the output, like changing it to a short URL, but this doesn't work on: [url=http://something.com]Hello![/url]
:(
Am I missing something?
 
I assume you're extending XenForo_BbCode_Formatter_Base::renderTagUrl?

In the latter format that isn't working, the URL is defined as $tag['option'] relevant code highlighted in red:

Rich (BB code):
public function renderTagUrl(array $tag, array $rendererStates)
{
if (!empty($tag['option']))​
{​
$url = $tag['option'];
$text = $this->renderSubTree($tag['children'], $rendererStates);​
echo $url;​
}​
else​
{​
$url = $this->stringifyTree($tag['children']);​
$text = urldecode($url);​
if (!utf8_check($text))​
{​
$text = $url;​
}​
$text = XenForo_Helper_String::censorString($text);​
if (!empty($rendererStates['shortenUrl']))​
{​
$length = utf8_strlen($text);​
if ($length > 100)​
{​
$text = utf8_substr_replace($text, '...', 35, $length - 35 - 45);​
}​
}​
$text = htmlspecialchars($text);​
}​

I'm guessing you've only applied your changes to the else statement where the URL is defined as $tag['children'].
 
Is extending AutoLink going to work?

As far as I can tell, autolinking only occurs when a user posts a link. It won't occur when people wrap a link in URL tags. Also would autolink ever be able to generate links in this format [url=http://www.google.co.uk]www.google.co.uk[/url]?

I see XenForo_Helper_String::prepareAutoLinkedUrl($url) looks like there should be a way for it to render a URL as an option with link text as the tag child but I can't seem to get it to work like that.

But yeah, it seems like the Autolink class would only apply to a small fraction of URLs posted on the board.
 
Is extending AutoLink going to work?
yes, it works, except for the already wrapped URLs...

As far as I can tell, autolinking only occurs when a user posts a link. It won't occur when people wrap a link in URL tags. Also would autolink ever be able to generate links in this format [url=http://www.google.co.uk]www.google.co.uk[/url]?
Yes it can! :D

I see XenForo_Helper_String::prepareAutoLinkedUrl($url) looks like there should be a way for it to render a URL as an option with link text as the tag child but I can't seem to get it to work like that.
yep, the same thing happens...
 
Top Bottom