From 234b000e481d105ae9026abccb93e9bc63564d6a Mon Sep 17 00:00:00 2001
From: Simon Ruggier <Simon80@gmail.com>
Date: Wed, 7 Sep 2011 18:42:42 -0400
Subject: [PATCH] Actually fix Firefox "file://" prefix path error
Firefox passes file arguments to Deluge as file:// URLs instead of local
paths, for some reason. In 1.3.2, these weren't handled at all, which
resulted in errors. Since then, a change was made to handle these URLs
by stripping the file:// off of the front of the URL and treating the
rest like a valid path. However, this isn't enough, since URLs also
escape special characters using %xx escape sequences. This change
handles those using the urllib.url2pathname function, which converts URL
escaped path components into local paths.
---
deluge/ui/gtkui/ipcinterface.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py
index ef6b104..fcea626 100644
a
|
b
|
|
37 | 37 | import sys |
38 | 38 | import os |
39 | 39 | import base64 |
| 40 | import urllib |
40 | 41 | |
41 | 42 | try: |
42 | 43 | import rencode |
… |
… |
def process_args(args): |
209 | 210 | client.core.add_torrent_magnet(arg, {}) |
210 | 211 | else: |
211 | 212 | # Just a file |
212 | | path = os.path.abspath(arg.replace('file://', '', 1)) |
| 213 | path = arg |
| 214 | if path.startswith("file://"): |
| 215 | path = urllib.url2pathname(path.replace('file://', '', 1)) |
| 216 | path = os.path.abspath(path) |
213 | 217 | log.debug("Attempting to add %s from external source..", path) |
214 | 218 | if not os.path.exists(path): |
215 | 219 | log.error("No such file: %s", path) |