Closed diogotito closed 1 year ago
Looking good! I'll merge this when I get back home. -------- Original message --------From: Diogo Tito Victor Marques notifications@github.com Date: 6/20/20 06:49 (GMT+01:00) To: mattydebie/bitwarden-rofi bitwarden-rofi@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [mattydebie/bitwarden-rofi] Handle quotes and backslashes in item names (#52) Fixes #35 My vault has an item that has quotes in the name, and it derails bwmenu in a way that forces me to pkill bwmenu I found that the problem is that the item and folder names are being directly used in some jq filters, artificially wrapped in quotes, like this: select(.name == \"$item_name\") If $item_name has quotes or backslashes, its expansion will create a jq syntax error. I found this solution on StackOverflow that makes jq slurp a string like $item_name from stdin and output the correctly JSON-encoded version of it, and decided to incorporate it in the script. select(.name == $(echo "$item_name" | jq -Rs)) I am confident that bitwarden-rofi will now be capable of handling the weirdest item names and folder names we can put in our vaults!
PS: I made an alternative branch where my jq_escape function gets the input string from stdin, but I'm afraid it makes the code that uses it a little harder to understand. It also shows that jq_escape is a bit useless by itself, but I believe it make it more obvious what's happening to the names.
You can view, comment on, or merge this pull request online at: https://github.com/mattydebie/bitwarden-rofi/pull/52
Commit Summary
Handle quotes in item names
File Changes
M
bwmenu
(4)
M
lib-bwmenu
(12)
Patch Links:
https://github.com/mattydebie/bitwarden-rofi/pull/52.patch https://github.com/mattydebie/bitwarden-rofi/pull/52.diff
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/mattydebie/bitwarden-rofi/pull/52", "url": "https://github.com/mattydebie/bitwarden-rofi/pull/52", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
Thanks! merge in db3427daccdb84fe34709f79a0705e296731e5f5
Fixes #35
My vault has an item that has quotes in the name, and it derails
bwmenu
in a way that forces me topkill bwmenu
I found that the problem is that the item and folder names are being directly used in some jq filters, artificially wrapped in quotes, like this:
If
$item_name
has quotes or backslashes, its expansion will create a jq syntax error.I found this solution on StackOverflow that makes jq slurp a string like
$item_name
from stdin and output the correctly JSON-encoded version of it, and decided to incorporate it in the script.I am confident that bitwarden-rofi will now be capable of handling the weirdest item names and folder names we can put in our vaults!
PS: I made an alternative branch where my
jq_escape
function gets the input string from stdin, but I'm afraid it makes the code that uses it a little harder to understand. It also shows thatjq_escape
is a bit useless by itself, but I believe it make it more obvious what's happening to the names.