Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: fapencio on July 31, 2014, 12:35:51 PM

Title: broken links when a url have the [] signs
Post by: fapencio on July 31, 2014, 12:35:51 PM
Hi, my problem is this: when a user post a link with have this signs: []  the url of link broken it, example:

http://www.sld.cu/galerias/pdf/sitios/tuberculosis/tb-labs-cultivo[2].pdf

in the above url, the link is broken in "cultivo" and when I clik in them, the web browser sends me to the wrong link that is broken

please help
Title: Re: broken links when a url have the [] signs
Post by: Arantor on July 31, 2014, 12:43:26 PM
There's no way to fix that, seeing how [ and ] are using in bbcode themselves.
Title: Re: broken links when a url have the [] signs
Post by: Steve on July 31, 2014, 02:16:43 PM
About the only option I see is to put the url in code or nobbc tags and have whoever needs the url copy and paste it into their browser's address bar.
Title: Re: broken links when a url have the [] signs
Post by: Kindred on July 31, 2014, 04:40:29 PM
http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid

answer 59...
Quote
The '[' and ']' characters are <reserved> characters and should be percent escaped if not used as delimiters in the scheme-specific syntax. The spec says:

    "URI producing applications should percent-encode data octets that correspond to characters in the reserved set unless these characters are specifically allowed by the URI scheme to represent data in that component."

(Note - the operative work here is "should", and not "shall" or "must". This is advisory, not prescriptive.)

The next sentence of the spec says this:

    "If a reserved character is found in a URI component and no delimiting role is known for that character, then it must be interpreted as representing the data octet corresponding to that character's encoding in US-ASCII."

(Note that the operative word is "must". This is saying what a URI means if someone ignores the advice of the previous sentence.)


so, it would seem that using unescaped  [ or ] in a URL is improper...
Title: Re: broken links when a url have the [] signs
Post by: fapencio on August 01, 2014, 11:19:08 AM
thanks for your answers, you are very kind, and their arguments are correct and entirely valid, but I am looking for a solution to my problem, please if anyone knows what code needs to be altered hope it helps me
Title: Re: broken links when a url have the [] signs
Post by: Arantor on August 01, 2014, 11:21:04 AM
It's not doable without rewriting the guts of SMF. I know, I've tried.
Title: Re: broken links when a url have the [] signs
Post by: margarett on August 01, 2014, 11:33:50 AM
Some time ago I remember seeing something about a php BBC parser
Maybe something like this can handle it?
http://jbbcode.com/

Of course, to use it in SMF means... To rewrite its guts :P
Title: Re: broken links when a url have the [] signs
Post by: Arantor on August 01, 2014, 01:58:05 PM
It's more than that, you'd have to rewrite part of that parser too.
Title: Re: broken links when a url have the [] signs
Post by: JBlaze on August 01, 2014, 04:47:47 PM
The easiest way to get around it is to use %5B and %5D respectively for [ and ].

Of course, this requires your members to know how to do this, and takes some time. But it's a workaround for now.

Example: http://www.sld.cu/galerias/pdf/sitios/tuberculosis/tb-labs-cultivo%5B2%5D.pdf

Edit: Phrasing
Title: Re: broken links when a url have the [] signs
Post by: Arantor on August 01, 2014, 04:52:52 PM
I wouldn't call that 'easily' ;)
Title: Re: broken links when a url have the [] signs
Post by: JBlaze on August 01, 2014, 04:54:04 PM
Good point. Edited to re-phrase :P