Skip to content

Commit

Permalink
correctly encode special characters in filenames
Browse files Browse the repository at this point in the history
fixes #22
  • Loading branch information
Kriechi committed Apr 4, 2020
1 parent 84ff2e1 commit 8c6eeb4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions DuetRRFOutputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ def _timestamp(self):
return ("time", datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S'))

def _send(self, command, query=None, next_stage=None, data=None):
enc_query = urllib.parse.urlencode(query or dict())
url = "{}rr_{}".format(self._url, command)

if not query:
query = dict()
enc_query = urllib.parse.urlencode(query, quote_via=urllib.parse.quote)
if enc_query:
command += '?' + enc_query
self._request = QtNetwork.QNetworkRequest(QUrl(self._url + "rr_" + command))
url += '?' + enc_query

self._request = QtNetwork.QNetworkRequest(QUrl(url))
self._request.setRawHeader(b'User-Agent', b'Cura Plugin DuetRRF')
self._request.setRawHeader(b'Accept', b'application/json, text/javascript')
self._request.setRawHeader(b'Connection', b'keep-alive')
Expand Down

0 comments on commit 8c6eeb4

Please sign in to comment.