firecat53 / urlscan

Mutt and terminal url selector (similar to urlview)
GNU General Public License v2.0
213 stars 37 forks source link

Detection of escaped URLs #50

Closed basxto closed 6 years ago

basxto commented 6 years ago

This is an feature request Detection of escaped URLs and unescaping them would be neat. Right now lines like mpv --no-video --loop https://www.youtube.com/watch\?v\=sTal8O7uMxg get detected as https://www.youtube.com/watch

firecat53 commented 6 years ago

And pushed a fix for this too on the develop branch. It works with your example...do you have other ones to test it with?

basxto commented 6 years ago

and unescaping them

The unescaping part is missing, it would be sufficient to strip any \, but I think that should only be done with an --unescape flag.

mpv --no-video --loop https://www.youtube.com/watch\?v\=sTal8O7uMxg
Playing: https://www.youtube.com/watch?v=sTal8O7uMxg
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
A: 00:00:09 / 01:11:17 (0%) Cache: 10s+828KB

Exiting... (Quit)

becomes

...
mpv --no-video --loop <URL> [1]
Playing: <URL> [2]
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
...

[1]   < https://www.youtube.com/watch\?v\=sTal8O7uMxg >
[2]   < https://www.youtube.com/watch?v=sTal8O7uMxg 

I would have expected

...
mpv --no-video --loop <URL> [1]
Playing: <URL> [1]
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
...

[1]   < https://www.youtube.com/watch?v=sTal8O7uMxg 
firecat53 commented 6 years ago

Why do you think a \ should only be removed from a URL when an --unescaped flag is passed? The whole idea is to open the URL in browser and \ isn't a legal URL character, so shouldn't they just be stripped out regardless?

basxto commented 6 years ago

https:\\github.com\firecat53\urlscan\ works, even with xdg-open 'https:\\github.com\firecat53\urlscan\'

Firefox and Chromium tend to translate it into https://github.com/firecat53/urlscan/. I don’t think it’s a legal url, but it appears that some people can’t distinguish slash and backslash.

firecat53 commented 6 years ago

Added 'u' to toggle unescaped URLs. Does that work as you envisioned?