Page 1 of 2

Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 6:04 pm
by wolfbeast
I recently migrated from 3.1 to 3.2 and something I rely on heavily changed:
Previously, when wrapping a URL in [ url ] tags it would retain the full displayed URL and make a link of it.
v3.2 however doesn't do this anymore and shortens the URL no matter if it's wrapped or not, removing this alternate behavior.

How do I get back to the 3.1 behavior? Is this considered a bug by the dev team? It is by me.

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 6:23 pm
by stevemaury
I'm not sure why it would be intended behavior. Report it in the Bug Tracker - http://tracker.phpbb.com/

You could use code tags, but the link would not be hot.

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 6:41 pm
by wolfbeast
stevemaury wrote:
Sat Apr 27, 2019 6:23 pm
I'm not sure why it would be intended behavior.
There's no way to display the full URL of the link people are going to click on the way it is now.
It's fine to magically shorten if just placed in text, but if a poster explicitly indicates it's a URL then it shouldn't be shortened. This behavior has existed for a long time (since 3.0 at least) and I didn't expect it to be changed.

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 6:42 pm
by stevemaury
I am agreeing with you. Report it to the Bug Tracker.

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 7:33 pm
by wolfbeast
I did and I got the door slammed in my face "This change was intentional", ticket closed, referring to a discussion that goes over my head about regexes.
https://tracker.phpbb.com/browse/PHPBB3-16033

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 8:04 pm
by wolfbeast
So, I'm guess I need to get help from the community for hacking the files myself then.

Source:

Code: Select all

1. {somelongurl}
2. [url]{somelongurl}[/url]
3. [url={somelongurl}]{somelongurl}[/url]
4. [url={somelongurl}]sometext[/url]
Current behavior (IMHO wrong):
1. {some...url}
2. {some...url}
3. {some...url}
4. sometext

If anything, 3 is even worse -- it should never touch the text between url= tags, even if it's a url.

Desired result:
1. {some...url}
2. {somelongurl}
3. {somelongurl}
4. sometext

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 8:25 pm
by stevemaury
THIS:

Code: Select all

[url=phpbb.com/community/viewtopic.php?p=15242196#p15242196]phpbb.com/community/viewtopic.php?p=15242196#p15242196[/url]
PRODUCES THIS:

phpbb.com/community/viewtopic.php?p=15242196#p15242196

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 8:35 pm
by wolfbeast
THIS:

Code: Select all

[url=http://xref.binaryoutcast.com/binoc-central/source/mozilla/application/palemoon/themes/windows/statusbar/overlay.css]http://xref.binaryoutcast.com/binoc-central/source/mozilla/application/palemoon/themes/windows/statusbar/overlay.css[/url]
PRODUCES THIS:

http://xref.binaryoutcast.com/binoc-cen ... verlay.css

Your URL is probably not shortened because it is a relative url to phpbb (is it even long enough?)

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 8:52 pm
by stevemaury
Leave off the http*:// and www. (if any)

Code: Select all

[url=microsoft.com/veryveryverylong_foldername/1234567890/veryveryverylong_filename.xxx]microsoft.com/veryveryverylong_foldername/1234567890/veryveryverylong_filename.xxx[/url]
microsoft.com/veryveryverylong_foldername/1234567890/veryveryverylong_filename.xxx

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 9:12 pm
by wolfbeast
stevemaury wrote:
Sat Apr 27, 2019 8:52 pm
Leave off the http*:// and www. (if any)
You can't do that. If the protocol is different than what you're on it will fail. The URL will be wrong.
Board runs https and you want to post an http url? Can't do it. Want to post an ftp address? can't do that either...
It's clearly a bug that it shortens every fully-formatted URL it encounters.

Try linking to

Code: Select all

ftp://microsoft.com/veryveryverylong_foldername/1234567890/veryveryverylong_filename.xxx
without it shortening.

ftp://microsoft.com/veryveryverylong_fo ... lename.xxx

Also, for quite a few domains the root domain and www.domain.tld are NOT interchangeable. so using www is often needed. And that can't be done either.
www.microsoft.com/veryveryverylong_fold ... lename.xxx

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 10:09 pm
by JoshyPHP
If you want to implement your own logic for shortening links, it's possible to do it via an extension. I haven't tried it but something like that should work:

Code: Select all

class listener implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
{
	public static function getSubscribedEvents()
	{
		return ['core.text_formatter_s9e_configure_after' => 'onConfigure'];
	}
	public function onConfigure($event)
	{
		$configurator->tags['LINK_TEXT']->filterChain->add(__CLASS__ . '::filterLinkText'))
			->resetParameters()
			->addParameterByName('tag')
			->addParameterByName('openTags');
	}
	public static function filterLinkText(s9e\TextFormatter\Parser\Tag $tag, array $openTags)
	{
		// Invalidate if the most recent open tag uses 5 chars, assumed to be "[url]"
		if (end($openTags)->getLen() === 5)
		{
			$tag->invalidate();
		}
	}
}

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 10:15 pm
by kinerity
There's an extension that enables full links. Full Links extension

Re: Disable short URL like in 3.1

Posted: Sat Apr 27, 2019 11:29 pm
by EA117
kinerity wrote:
Sat Apr 27, 2019 10:15 pm
There's an extension that enables full links. Full Links extension
Nice. Couldn't be an more elegant. Not withstanding that there is still "no control for when the URL should and should not be shortened" as with phpBB 3.1. i.e. Now "all URLs are non-shortened" with the extension, versus "all are shortened" in phpBB 3.2 without the extension. Still a really great solution.

I understand why removing the LINK_TEXT tag that was constructed prevents the shortened URL from being displayed. (For all cases; not just where [url] was used in any specific way.) But I'm curious whether you recall knowledge or investigation of the issue concluding anything about why the link shortening wasn't already "conditional" in phpBB 3.2.x, such that the extension was necessary.

The code to make shortening conditional on how [url] was used appears to be there in how the text-formatter and helpers were implemented in 3.2.x. And the Area51 discussion thread cited seems to conclude that they believe currently the [url=longurl]longurl[/url] usage actually was not affected, and was not shortening the displayed URL; and only the "other cases" would intentionally shorten the URL, and this was agreed to be satisfactory. But that's not the ultimate behavior in 3.2.x, and the URL is "always" shortened.

I had a couple of theories, but nothing I've have time to prove under debugging yet:

One is that the code actually does leave the link non-shortened with the the [url=longurl]longurl[/url] usage, as seemingly the code intends. But then some unintentional double- or re-parse treats that "non-shortened" URL text created by the BBCode parsing as though that text needs AutoLink processing applied to it, and that's when the URL in the "for display only" text becomes intentionally shortened anyway.

The other is wanting to test whether the link_helper::should_shorten() string match for "[url]" is actually working, versus whether there is already something different like "[url:uid]" or similar in the string being tested at that point.

Re: Disable short URL like in 3.1

Posted: Sun Apr 28, 2019 12:47 am
by JoshyPHP
I haven't really read this last post but it will probably get fixed by this: https://tracker.phpbb.com/browse/PHPBB3-16034

Re: Disable short URL like in 3.1

Posted: Sun Apr 28, 2019 2:03 am
by EA117
JoshyPHP wrote:
Sun Apr 28, 2019 12:47 am
I haven't really read this last post but it will probably get fixed by this: https://tracker.phpbb.com/browse/PHPBB3-16034
The #5577 commit changes are far enough above my pay grade to keep me from understanding what condition they're resolving, but I'm happy not to poke it with a stick. 😃

What I can confirm is that those commit changes address the issue in my usage here, too. Meaning the behavior now matches what seemed to be concluded in the the Area51 thread; which was that [url=...]...[/url] usage should not be shortened, but [url]...[/url] and raw ... usage (without any BBCode) were appropriate for the URL to be shortened.

Older existing messages were also fixed, once a manual reparse was performed after implementing the #5577 commit changes in /phpbb/textformatter/s9e/link_helper.php.

Thanks for giving some attention to this, and making the actual controllable behavior available.