mirror of https://github.com/vitalif/phantomjs
Handle badly encoded URL's
parent
e93bea5a21
commit
d19901cdf8
|
@ -22,6 +22,7 @@ from PyQt4.QtCore import qDebug, qWarning
|
||||||
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkDiskCache, \
|
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkDiskCache, \
|
||||||
QNetworkRequest
|
QNetworkRequest
|
||||||
|
|
||||||
|
from utils import encode
|
||||||
from plugincontroller import Bunch, do_action
|
from plugincontroller import Bunch, do_action
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ class NetworkAccessManager(QNetworkAccessManager):
|
||||||
else:
|
else:
|
||||||
qWarning('Unexpected HTTP Operation Type')
|
qWarning('Unexpected HTTP Operation Type')
|
||||||
|
|
||||||
qDebug('URL %s' % req.url().toString())
|
qDebug('URL %s' % encode(req.url().toString()))
|
||||||
|
|
||||||
do_action('NetworkAccessManagerCreateRequestPre', Bunch(locals()))
|
do_action('NetworkAccessManagerCreateRequestPre', Bunch(locals()))
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ class NetworkAccessManager(QNetworkAccessManager):
|
||||||
|
|
||||||
def handleFinished(self, reply):
|
def handleFinished(self, reply):
|
||||||
qDebug('HTTP/1.1 Response')
|
qDebug('HTTP/1.1 Response')
|
||||||
qDebug('URL %s' % reply.url().toString())
|
qDebug('URL %s' % encode(reply.url().toString()))
|
||||||
code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||||
if code:
|
if code:
|
||||||
qDebug('Status code: %d' % code)
|
qDebug('Status code: %d' % code)
|
||||||
|
|
|
@ -17,7 +17,10 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import argparse, sys
|
import sys
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from unicodedata import normalize
|
||||||
|
|
||||||
from plugincontroller import Bunch, do_action
|
from plugincontroller import Bunch, do_action
|
||||||
|
|
||||||
|
@ -92,6 +95,10 @@ def argParser():
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def encode(text, encoding='UTF-8', method='ignore'):
|
||||||
|
return normalize('NFKD', text).encode(encoding, method)
|
||||||
|
|
||||||
|
|
||||||
class MessageHandler:
|
class MessageHandler:
|
||||||
def __init__(self, verbose):
|
def __init__(self, verbose):
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
Loading…
Reference in New Issue