mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
ShrinkUrl & core: Fix encoding issue related to getUrlFd.
This commit is contained in:
parent
5446ac13c5
commit
ab011a6618
@ -29,6 +29,7 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import urllib
|
import urllib
|
||||||
@ -266,6 +267,8 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
headers['content-type'] = 'application/json'
|
headers['content-type'] = 'application/json'
|
||||||
data = json.dumps({'longUrl': url})
|
data = json.dumps({'longUrl': url})
|
||||||
text = utils.web.getUrl(self._gooApi, data=data, headers=headers)
|
text = utils.web.getUrl(self._gooApi, data=data, headers=headers)
|
||||||
|
if sys.version_info[0] >= 3 and isinstance(text, bytes):
|
||||||
|
text = text.decode()
|
||||||
googl = json.loads(text)['id']
|
googl = json.loads(text)['id']
|
||||||
if googl:
|
if googl:
|
||||||
self.db.set('goo', url, googl)
|
self.db.set('goo', url, googl)
|
||||||
|
@ -108,6 +108,8 @@ def getUrlFd(url, headers=None, data=None, timeout=None):
|
|||||||
a dict and string, respectively, as per urllib2.Request's arguments."""
|
a dict and string, respectively, as per urllib2.Request's arguments."""
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = defaultHeaders
|
headers = defaultHeaders
|
||||||
|
if sys.version_info[0] >= 3 and isinstance(data, str):
|
||||||
|
data = data.encode()
|
||||||
try:
|
try:
|
||||||
if not isinstance(url, urllib2.Request):
|
if not isinstance(url, urllib2.Request):
|
||||||
(scheme, loc, path, query, frag) = urlparse.urlsplit(url)
|
(scheme, loc, path, query, frag) = urlparse.urlsplit(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user