Invalid characters in scheme give wrong error
jacobmealey opened this issue · 2 comments
When providing trurl with a scheme that has invalid characters, it returns trurl note: Port number was not a decimal number between 0 and 65535
This should probably be an error if the scheme is bad, and it should report that the scheme had some invalid characters. This should report trurl note: Bad scheme
similar to when a bad hostname is provided.
A few of the tests I ran are:
trurl "example.com" --set "scheme=ftp="
trurl "example.com" --set "scheme=ft=p"
trurl "example.com" --set "scheme=ft<p"
trurl --url "ht<p://example.com"
trurl --url "ht<p://example.com:1000"
Which all give the same error of trurl note: Port number was not a decimal number between 0 and 65535
The ones where you set the scheme only should at least give a better error.
The ones that set the URL are more difficult:
Since a scheme can only be alphanumerical, something like ht<p://example.com
is treated as a scheme-less URL, so ht<p
(before the hostname characters are valided) is an attempted hostname but what follows the host name is a colon without a port number, which is illegal. I'm sure this can be improved, probably for example by checking the host name to be valid before it checks (and erroring out because of) the port number.
At least the full URL ones are a curl issue, possible the first ones are as well.
I think we just have to accept this for the time being unless someone can figure out a clever way to improve this...