Storage and display of links

Discussion forum for MOD Writers regarding MOD Development.
Locked
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Storage and display of links

Post by asinshesq »

When a user posts text that includes a link, phpbb3 stores the link in the database in two different ways depending on whether the link includes 'http://'.

1. If the post text includes 'http://' the link gets stored like this:
<!-- m --><a class="postlink" href="http://www.test.com">http://www.test.com</a><!-- m -->

2. If the post text does not include 'http://' the link gets stored like this:
<!-- w --><a class="postlink" href="http://www.test.com">www.test.com</a><!-- w -->

The format in #2 allows phpbb3 to display the link in viewtopic without 'http://' (matching the way the poster posted it). All that makes sense to me except for why the actual href in #2 includes 'http://'. So, anyone know why does it that?

The reason I am asking is because I am tinkering with some regex to modify post text so that links can be included properly in an email notification. That's easy enough to do except I am having a hard time deciding whether in the case of a link in the form of #2 above O should use the stored href reference ('http://www.test.com' in this case) or the stored text that appears between the anchor tags ('www.test.com in this case'). I would just include the one that appears between the achor tags (it seems to show up as a clickable link in plain text emails) but I wanted to see if anyone knows why phpbb3 doesn't use that in the actual way it stores the href in posts. Thoughts?

And btw, out of curiousity, why does the comment <!-- w --> (or <!-- m -->) get stored with the text in the first place?
User avatar
AmigoJack
Registered User
Posts: 5774
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Storage and display of links

Post by AmigoJack »

asinshesq wrote:When a user posts text that includes a link, phpbb3 stores the link
No, you mean a URL. A link is a combination of a URL and a display text.
asinshesq wrote:If the post text includes 'http://'
No, if the URL has a protocol - http is only one of many. More precisely a combination of latin letters and ciphers are allowed plus ://. Example: s00p://void.void
asinshesq wrote:If the post text does not include 'http://'
More precisely: if no protocol is recognized.
asinshesq wrote:why the actual href in #2 includes 'http://'
Probably reacting on lazy software users requests. If you wouldn't add a protocol, the URL would be relative, which means the protocol would always be the one of the current site. Example: phpbb.com runs on https, so a URL of mikerowsoft.com would make your browser automatically prepend https:// to it. Which is fatal, because that site is accessible via http only.
asinshesq wrote:modify post text so that links can be included properly in an email notification
I can't follow you on that: e-mail notofications are plain text and never have post text in it.
asinshesq wrote:it seems to show up as a clickable link in plain text emails
Be aware that e-mail clients might have their own mechanism to make URLs clickable, so in doubt always use an absolute URL.
asinshesq wrote:why does the comment <!-- w --> (or <!-- m -->) get stored
So the board knows how to convert the text back to the actual input if the post is about to be edited.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: Storage and display of links

Post by asinshesq »

Thanks, amigojack.
Locked

Return to “[3.0.x] MOD Writers Discussion”