Eclectic Media Git toast / e035db9
Made text passed from user escaped by shlex.quote Ariana Giroux 1 year, 1 month ago
2 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
33 from toast import toast
44
55 from time import time
6 from shlex import quote
67
78 time_start = time()
89
3334
3435
3536 def test_parse_command():
36 test_message = _Message('test')
37 test_message = _Message('test ! (testing)')
3738 result = _parse_command(test_message)
3839
3940 assert type(result) is list
4041 assert len(result) == 3
4142 assert result[0] == 'powershell.exe'
4243 assert result[1] == 'New-BurntToastNotification'
43 assert result[2] == '-Text %s' % str(test_message)
44 assert result[2] == '-Text %s' % quote(str(test_message))
4445
4546
4647 def test_toast(capsys):
44 >>> toast('test', title='test title')
55 """
66 from subprocess import Popen, PIPE
7 from shlex import quote
78
89
910 __version__ = 0.3
4344 :rtype: str
4445 """
4546 if self.title != '':
46 return "'%s', '%s'" % (self.title, self.body)
47 return "%s, %s" % (self.title, self.body)
4748 else:
4849 return self.body
4950
5657 :py:func:`subprocess.Popen` ready argument list
5758 :rtype: list
5859 """
59 return ['powershell.exe', 'New-BurntToastNotification', '-Text %s' % message]
60 return ['powershell.exe', 'New-BurntToastNotification',
61 '-Text %s' % quote(str(message))]
6062
6163
6264 def toast(body, title=''):