Skip to content

Commit

Permalink
Fix quoting of query string and dl of answer sound
Browse files Browse the repository at this point in the history
  • Loading branch information
solsticedhiver committed Dec 25, 2020
1 parent c5dcd1d commit 2d10416
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mentalcalculation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# mentalcalculation - version 0.4.2
# mentalcalculation - version 0.4.3
# Copyright (C) 2008-2020, solsTiCe d'Hiver <[email protected]>

# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -64,7 +64,7 @@
DIGIT = dict([(i,(int('1'+'0'*(i-1)), int('9'*i))) for i in range(1,10)])

appName = 'mentalcalculation'
appVersion = '0.4.2'
appVersion = '0.4.3'

SHARE_PATH = '.'
SHARE_PATH = pathlib.Path(SHARE_PATH).absolute()
Expand Down Expand Up @@ -528,7 +528,7 @@ def downloadSounds(self):
t = ' '.join(list(t)).replace('- ', '-')
if t not in self.sounds:
self.query.update({'number': t, 'lang': LANG})
query_string = '&'.join(f'{k}={v}' for k,v in self.query.items())
query_string = '&'.join(f'{k}={urllib.parse.quote(v)}' for k,v in self.query.items())
url = f'{APIURL}?{query_string}'
t = Thread(target=dl_thread, args=(url, t, self.sounds, self.ui.statusbar, self.tr, nb_dls))
t.start()
Expand All @@ -539,7 +539,8 @@ def downloadSounds(self):
if self.one_digit:
t = ' '.join(list(t)).replace('- ', '-')
if t not in self.sounds:
query_string = '&'.join(f'{k}={v}' for k,v in self.query.items())
self.query.update({'number': t, 'lang': LANG})
query_string = '&'.join(f'{k}={urllib.parse.quote(v)}' for k,v in self.query.items())
url = f'{APIURL}?{query_string}'
t = Thread(target=dl_thread, args=(url, t, self.sounds, self.ui.statusbar, self.tr, nb_dls))
t.start()
Expand Down

0 comments on commit 2d10416

Please sign in to comment.