Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Better URL Regex
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Forums Feedback
View previous topic :: View next topic  
Author Message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 218

PostPosted: Fri Jul 21, 2017 7:18 pm    Post subject: Better URL Regex Reply with quote

Hello,

Some valid URLs are not accepted by the regular expression (or other matching algorithm) the forum uses to detect URLs. This means that they can't be replaced with link text and that automatic hyperlinking might fail to link to the right page.

Examples:

[url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx]Link Text[/url]
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 11448

PostPosted: Sat Jul 22, 2017 12:26 am    Post subject: Reply with quote

Your criticism is correct, but there is a nuance. You can still link to such pages with explicit url tags if you manually escape the offending characters. In this case, the parentheses need to be changed to their escaped equivalents %28 and %29. This is not convenient, but it at least provides a way to use such links.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1338
Location: United Kingdom

PostPosted: Sat Jul 22, 2017 1:30 am    Post subject: Reply with quote

There are several Web sites for encoding and decoding URLs, but I quite like the following Python 2 command-line approach:

Code:
$ alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
$ alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'

Code:
$ urlencode '(v=vs.85).aspx'
%28v%3Dvs.85%29.aspx

Code:
$ urldecode '%28v%3Dvs.85%29.aspx'
(v=vs.85).aspx


Beats trying to remember the percent codes.

Code:

[url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989%28v%3Dvs.85%29.aspx]Link Text[/url]


Ref. https://unix.stackexchange.com/a/159254
_________________
Clevo W230SS: amd64, OpenRC, nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64, OpenRC, xf86-video-ati, dual booting with Win 7 Pro 64-bit.
KDE on both laptops.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Forums Feedback All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum