Unable to `get` entries containing colons in the name
sareyko opened this issue · 1 comments
Ever since implementing URI matching (see a864366) trying to get entries containing a colon :
in the name field fails.
Example
$ rbw list
...
Example: not an URI
...
$ rbw get 'Example: not an URI'
rbw get: couldn't find entry for 'example: not an URI': no entry found
Note how the error message lower cases the string preceding the colon.
More details
Separating "Example" from the colon in the name yields the desired results:
$ rbw list
...
Example : not an URI
...
$ rbw get 'Example : not an URI'
secret
Cause
After digging through the code and having a play with Rusts url
crate I'm pretty sure the issue lies in the usage of Url::parse()
in parse_needle()
to determine if the given string is (an UUID,) an URL or just a name.
Lines 37 to 46 in f0b7969
Url::parse()
seems to return Ok
for every string not containing any whitespace that is followed by a colon and optional text.
Here's a link to Rust Playground containing some example strings to run throug Url::parse()
: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=4b84a31eaa0520308fcf6c6a0095f6e9
Possible solution
I can't think of a good solution to the problem other than maybe implementing a fallback mechanism that treats the first argument given to get
as name when an URL (according to Url::parse()
) is detected but no entry with this URL is found.