Skip to content

Commit

Permalink
Merge pull request #3510 from xoriole/add_directory_quote_plus
Browse files Browse the repository at this point in the history
Fixes for quotes on file URI
  • Loading branch information
qstokkink authored Mar 16, 2018
2 parents 08cb652 + 4f7be44 commit 2aceea6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Tribler/Core/Modules/restapi/downloads_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

import logging
from urllib import unquote_plus

from twisted.web import http, resource
from twisted.web.server import NOT_DONE_YET
from Tribler.Core.DownloadConfig import DownloadStartupConfig
Expand Down Expand Up @@ -290,7 +292,7 @@ def on_error(error):
request.finish()

download_deferred = self.session.start_download_from_uri(
unicode(parameters['uri'][0], 'utf-8'), download_config)
unquote_plus(unicode(parameters['uri'][0], 'utf-8')), download_config)
download_deferred.addCallback(download_added)
download_deferred.addErrback(on_error)

Expand Down
2 changes: 1 addition & 1 deletion Tribler/Core/Modules/restapi/torrentinfo_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def on_lookup_error(failure):
uri = unicode(request.args['uri'][0], 'utf-8')
if uri.startswith('file:'):
try:
filename = url2pathname(uri[5:])
filename = url2pathname(uri[5:].replace("+", " "))
metainfo_deferred.callback(bdecode(fix_torrent(filename)))
except TypeError:
request.setResponseCode(http.INTERNAL_SERVER_ERROR)
Expand Down
2 changes: 1 addition & 1 deletion TriblerGUI/tribler_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def on_add_torrent_browse_dir(self):
def on_confirm_add_directory_dialog(self, action):
if action == 0:
for torrent_file in self.selected_torrent_files:
escaped_uri = quote_plus((u"file:%s" % torrent_file).encode('utf-8'))
escaped_uri = u"file:%s" % quote_plus((torrent_file).encode('utf-8'))
self.perform_start_download_request(escaped_uri,
get_gui_setting(self.gui_settings,
"default_anonymity_enabled", True, is_bool=True),
Expand Down

0 comments on commit 2aceea6

Please sign in to comment.