Skip to content

unquoted note body fails #80

@r2evans

Description

@r2evans

Not a huge surprise, but notes with quotes in the body break sending notes:

root@localhost# ./pushbullet push mydev note "msg" "hello world"
Sending to device MYDEV
root@localhost# ./pushbullet push mydev note "msg" "hello \"world\""
Sending to device MYDEV
Error submitting the request. The error message was: {"error":{"code":"invalid_request","type":"invalid_request","message":"Failed to decode JSON body.","cat":"(=^‥^=)"},"error_code":"invalid_request"}

This can be averted with something like the following (which includes the posix-ification from my posix PR):

body=$(echo "$body" | sed -e 's/\n/\\n/g' -e 's/"/\\"/g')

Though I haven't come up with a string that would constitute an injection attack, it seems prudent to guard against inadvertent interpretation. (I'm doing this because I find it handy to have easily parsed message bodies; whether using CSV or JSON in the message body, it's not hard to conceive of situations where having some components quoted might be useful.)

There may be other shell escaping that might be necessary; I haven't investigated possible problems yet. Likewise, it might be a good idea to do this for the note title as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions