Skip to content

Commit

Permalink
patch: fixes possible injection issue for notify-send
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Nov 9, 2020
1 parent 6cd6cb9 commit 2d3927b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ module.exports.constructArgumentList = function (options, extra) {
};

initial.forEach(function (val) {
args.push(escapeFn(val));
if (typeof val === 'string') {
args.push(escapeFn(val));
}
});
for (var key in options) {
if (
Expand Down
11 changes: 11 additions & 0 deletions test/notify-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ describe('notify-send', function () {
notifier.notify({ message: 'some\n "me\'ss`age`"' });
});

it.only('should only include strings as arguments', function (done) {
var expected = ['"HACKED"', '--expire-time', '"10000"'];

expectArgsListToBe(expected, done);
var notifier = new Notify({ suppressOsdCheck: true });
var options = JSON.parse(
'{"title":"HACKED", "message":["`touch HACKED`"]}'
);
notifier.notify(options);
});

it('should send additional parameters as --"keyname"', function (done) {
var expected = [
'"title"',
Expand Down

0 comments on commit 2d3927b

Please sign in to comment.