OliveTin icon indicating copy to clipboard operation
OliveTin copied to clipboard

Feature Request: Add URL as an argument type

Open FunctionDJ opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. I'm using Archivebox which doesn't have an API yet that can be easily used by an Android app like [HTTP Shortcuts(https://http-shortcuts.rmy.ch/) in order to able to use the share function on Android to send a URL to Archivebox. OliveTin allows me to get around this by running ArchiveBox's Docker CLI using it's own API as a proxy of sorts, but i need to use the very_dangerous_raw_string argument type, which is obviously undesirable.

Describe the solution you'd like Add a url argument type which could use govalidator.IsURL() like urlregex.com recommends. I'm not 100% sure but this should reduce the attack surface in most cases where a URL can be used.

Describe alternatives you've considered It's possible to run JavaScript code before sending a request with HTTP Shortcut, so it might be possible to convert URLs into a safer format that's more restrictive on OliveTin's end, which will then need to be decoded (via shell?) to be used with ArchiveBox for example.

Additional context Example command to add a URL to ArchiveBox when running in Docker:
docker-compose run archivebox add 'https://example.com/some/url/here'

FunctionDJ avatar Jul 27 '22 09:07 FunctionDJ

Hey, this totally makes sense and is something I need to do - the regex for URLs is pretty complex though! :-)

I'll take a look.

jamesread avatar Aug 27 '22 16:08 jamesread

If the regex is complex, i suggest using an known and proven library instead, like govalidator.

FunctionDJ avatar Oct 19 '22 11:10 FunctionDJ

Hey, thanks for reminding me about this. I haven't heard of govalidator before, and I had a quick look, but then I just remembered that of course the Golang standard library has many functions for already validiating URLs - so of course I just used that :-)

Just added it now in commit 08a1ac2591cf1ed90762583b829d4a44279f2650 - so this will make the next release!

I just need to document this; https://github.com/OliveTin/docs.olivetin.app/issues/3

jamesread avatar Oct 19 '22 12:10 jamesread

This feature was released in 2022-10-19.

jamesread avatar Oct 21 '22 13:10 jamesread