mikaelbr / node-notifier

A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
MIT License
5.72k stars 323 forks source link

notify-send backend fails when user string starts with "-" #396

Open JGCarroll opened 2 years ago

JGCarroll commented 2 years ago

Related discussion: https://github.com/laurent22/joplin/issues/6029

Node-Notifier creates notify-send commands with the logical syntax of notify-send $PARAMS $INPUT

In the event the string for the title/body in $INPUT begins with -, notify-send aborts the command because it interprets the string as a parameter it can't recognise. The fix for this is to create a clear separation between parameters and input, by appending -- between the two, so that parameter handling is disabled on the raw input. notify-send $PARAMS -- $INPUT

As a concrete example from the linked issue: notify-send --icon "/snap/joplin-desktop/23/opt/joplin-desktop/resources/build/icons/512x512.png" --expire-time "10000" "To do" "- [ ] plans for today"

fails, whereas

notify-send --icon "/snap/joplin-desktop/23/opt/joplin-desktop/resources/build/icons/512x512.png" --expire-time "10000" -- "To do" "- [ ] plans for today"

works just fine. It'd be ideal if notify-send would include this by default to prevent this from occuring.

Thanks in advance for any assistance you can offer :)