Use custom urlencode function. fixes #121
This commit is contained in:
1 parent
8b80c50d89
commit
fd462514c3
22 files changed
+79
-66
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
from string import ascii_letters, digits
|
||||
from urllib import quote_plus
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
@@ -19,7 +20,7 @@ def simplifyString(original):
|
||||
|
||||
def toUnicode(original, *args):
|
||||
try:
|
||||
if type(original) is unicode:
|
||||
if isinstance(original, unicode):
|
||||
return original
|
||||
else:
|
||||
try:
|
||||
@@ -35,7 +36,7 @@ def toUnicode(original, *args):
|
||||
return toUnicode(ascii_text)
|
||||
|
||||
def ek(original, *args):
|
||||
if type(original) in [str, unicode]:
|
||||
if isinstance(original, (str, unicode)):
|
||||
try:
|
||||
from couchpotato.environment import Env
|
||||
return original.decode(Env.get('encoding'))
|
||||
@@ -53,3 +54,19 @@ def isInt(value):
|
||||
|
||||
def stripAccents(s):
|
||||
return ''.join((c for c in unicodedata.normalize('NFD', toUnicode(s)) if unicodedata.category(c) != 'Mn'))
|
||||
|
||||
def tryUrlencode(s):
|
||||
new = u''
|
||||
if isinstance(s, (dict)):
|
||||
for key, value in s.iteritems():
|
||||
new += u'&%s=%s' % (key, tryUrlencode(value))
|
||||
|
||||
return new[1:]
|
||||
else:
|
||||
for letter in toUnicode(s):
|
||||
try:
|
||||
new += quote_plus(letter)
|
||||
except:
|
||||
new += letter
|
||||
|
||||
return new
|
||||
@@ -1,3 +1,4 @@
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.helpers.variable import natcmp
|
||||
from flask.globals import current_app
|
||||
from flask.helpers import json
|
||||
@@ -25,7 +26,7 @@ def getParams():
|
||||
|
||||
for item in nested:
|
||||
if item is nested[-1]:
|
||||
current[item] = unquote_plus(value)
|
||||
current[item] = toUnicode(unquote_plus(value)).encode('utf-8')
|
||||
else:
|
||||
try:
|
||||
current[item]
|
||||
@@ -34,7 +35,7 @@ def getParams():
|
||||
|
||||
current = current[item]
|
||||
else:
|
||||
temp[param] = unquote_plus(value)
|
||||
temp[param] = toUnicode(unquote_plus(value)).encode('utf-8')
|
||||
|
||||
return dictToList(temp)
|
||||
|
||||
@@ -56,7 +57,7 @@ def dictToList(params):
|
||||
|
||||
def getParam(attr, default = None):
|
||||
try:
|
||||
return unquote_plus(getattr(flask.request, 'args').get(attr, default))
|
||||
return toUnicode(unquote_plus(getattr(flask.request, 'args').get(attr, default))).encode('utf-8')
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
Reference in new issue
Block a user