Handle badly encoded URL's

1.2
IceArmy 2011-06-01 00:26:06 -07:00
parent e93bea5a21
commit d19901cdf8
2 changed files with 11 additions and 3 deletions

View File

@ -22,6 +22,7 @@ from PyQt4.QtCore import qDebug, qWarning
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkDiskCache, \
QNetworkRequest
from utils import encode
from plugincontroller import Bunch, do_action
@ -56,7 +57,7 @@ class NetworkAccessManager(QNetworkAccessManager):
else:
qWarning('Unexpected HTTP Operation Type')
qDebug('URL %s' % req.url().toString())
qDebug('URL %s' % encode(req.url().toString()))
do_action('NetworkAccessManagerCreateRequestPre', Bunch(locals()))
@ -71,7 +72,7 @@ class NetworkAccessManager(QNetworkAccessManager):
def handleFinished(self, reply):
qDebug('HTTP/1.1 Response')
qDebug('URL %s' % reply.url().toString())
qDebug('URL %s' % encode(reply.url().toString()))
code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
if code:
qDebug('Status code: %d' % code)

View File

@ -17,7 +17,10 @@
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
@ -92,6 +95,10 @@ def argParser():
return parser
def encode(text, encoding='UTF-8', method='ignore'):
return normalize('NFKD', text).encode(encoding, method)
class MessageHandler:
def __init__(self, verbose):
self.verbose = verbose