summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyload/api/__init__.py6
-rw-r--r--pyload/manager/PluginManager.py3
-rw-r--r--pyload/plugins/Crypter.py6
-rw-r--r--pyload/utils/__init__.py5
4 files changed, 12 insertions, 8 deletions
diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py
index ab410bbc6..399117845 100644
--- a/pyload/api/__init__.py
+++ b/pyload/api/__init__.py
@@ -12,7 +12,7 @@ from pyload.datatype.PyFile import PyFile
from pyload.utils.packagetools import parseNames
from pyload.network.RequestFactory import getURL
from pyload.remote import activated
-from pyload.utils import compare_time, freeSpace, html_unescape, save_filename
+from pyload.utils import compare_time, freeSpace, safe_filename
if activated:
try:
@@ -301,11 +301,11 @@ class Api(Iface):
:return: package id of the new package
"""
if self.core.config['general']['folder_per_package']:
- folder = urlparse(html_unescape(name)).path.split("/")[-1]
+ folder = urlparse(name).path.split("/")[-1]
else:
folder = ""
- folder = save_filename(folder)
+ folder = safe_filename(folder)
pid = self.core.files.addPackage(name, folder, dest)
diff --git a/pyload/manager/PluginManager.py b/pyload/manager/PluginManager.py
index 339281d43..92b5e2c7d 100644
--- a/pyload/manager/PluginManager.py
+++ b/pyload/manager/PluginManager.py
@@ -10,6 +10,7 @@ from os import listdir, makedirs
from os.path import isdir, isfile, join, exists, abspath
from sys import version_info
from traceback import print_exc
+from urllib import unquote
from SafeEval import const_eval as literal_eval
@@ -201,6 +202,8 @@ class PluginManager(object):
if type(url) not in (str, unicode, buffer):
continue
+ url = unquote(url)
+
if last and last[2]['re'].match(url):
res.append((url, last[0], last[1]))
continue
diff --git a/pyload/plugins/Crypter.py b/pyload/plugins/Crypter.py
index badc77282..e0fe2bc0f 100644
--- a/pyload/plugins/Crypter.py
+++ b/pyload/plugins/Crypter.py
@@ -3,7 +3,7 @@
from urlparse import urlparse
from pyload.plugins.Plugin import Plugin
-from pyload.utils import decode, html_unescape, safe_filename
+from pyload.utils import decode, safe_filename
class Crypter(Plugin):
@@ -98,9 +98,9 @@ class Crypter(Plugin):
elif not folder_per_package or name != folder:
if not folder:
- folder = urlparse(html_unescape(name)).path.split("/")[-1]
+ folder = urlparse(name).path.split("/")[-1]
- setFolder(folder)
+ setFolder(safe_filename(folder))
self.logDebug("Set package %(name)s folder to: %(folder)s" % {"name": name, "folder": folder})
elif folder_per_package:
diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py
index 004274c3e..39a3ae751 100644
--- a/pyload/utils/__init__.py
+++ b/pyload/utils/__init__.py
@@ -8,6 +8,7 @@ import time
import re
from os.path import join
from string import maketrans
+from urllib import unquote
from htmlentitydefs import name2codepoint
# abstraction layer for json operations
@@ -58,7 +59,7 @@ def remove_chars(string, repl):
def safe_filename(name):
""" remove bad chars """
- name = name.encode('ascii', 'replace') # Non-ASCII chars usually breaks file saving. Replacing.
+ name = unquote(name).encode('ascii', 'replace') # Non-ASCII chars usually breaks file saving. Replacing.
if os.name == 'nt':
return remove_chars(name, u'\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31\32'
u'\33\34\35\36\37/?%*|"<>')
@@ -84,7 +85,7 @@ def save_join(*args):
if sys.getfilesystemencoding().startswith('ANSI'):
def fs_encode(string):
- return save_path(encode(string))
+ return safe_filename(encode(string))
fs_decode = decode #decode utf8