forked from openlp/openlp
Better fix for the encoding and related issue, less doube-encoding. Now we unquote the characters after JSON has decoded it's bits.
This commit is contained in:
parent
00390ed688
commit
4ed5c33584
@ -283,8 +283,7 @@ window.OpenLP = {
|
|||||||
$.mobile.changePage("#service-manager");
|
$.mobile.changePage("#service-manager");
|
||||||
},
|
},
|
||||||
escapeString: function (string) {
|
escapeString: function (string) {
|
||||||
return string.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(
|
return string.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")
|
||||||
/#/g, "%23").replace(/;/g, "%3B").replace(/\+/g, "%2B")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Service Manager
|
// Service Manager
|
||||||
|
@ -115,6 +115,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import urllib
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtNetwork
|
from PyQt4 import QtCore, QtNetwork
|
||||||
@ -310,11 +311,14 @@ class HttpConnection(object):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'ready to read socket')
|
log.debug(u'ready to read socket')
|
||||||
if self.socket.canReadLine():
|
if self.socket.canReadLine():
|
||||||
data = self.socket.readLine()
|
data = str(self.socket.readLine())
|
||||||
data = QtCore.QByteArray.fromPercentEncoding(data)
|
try:
|
||||||
data = unicode(data, 'utf8')
|
log.debug(u'received: ' + data)
|
||||||
log.debug(u'received: ' + data)
|
except UnicodeDecodeError:
|
||||||
words = data.split(u' ')
|
# Malicious request containing non-ASCII characters.
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
|
words = data.split(' ')
|
||||||
response = None
|
response = None
|
||||||
if words[0] == u'GET':
|
if words[0] == u'GET':
|
||||||
url = urlparse.urlparse(words[1])
|
url = urlparse.urlparse(words[1])
|
||||||
@ -423,6 +427,7 @@ class HttpConnection(object):
|
|||||||
Send an alert.
|
Send an alert.
|
||||||
"""
|
"""
|
||||||
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
||||||
|
text = urllib.unquote(text)
|
||||||
Receiver.send_message(u'alerts_text', [text])
|
Receiver.send_message(u'alerts_text', [text])
|
||||||
return HttpResponse(json.dumps({u'results': {u'success': True}}),
|
return HttpResponse(json.dumps({u'results': {u'success': True}}),
|
||||||
{u'Content-Type': u'application/json'})
|
{u'Content-Type': u'application/json'})
|
||||||
@ -517,6 +522,7 @@ class HttpConnection(object):
|
|||||||
The plugin name to search in.
|
The plugin name to search in.
|
||||||
"""
|
"""
|
||||||
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
||||||
|
text = urllib.unquote(text)
|
||||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||||
if plugin.status == PluginStatus.Active and \
|
if plugin.status == PluginStatus.Active and \
|
||||||
plugin.mediaItem and plugin.mediaItem.hasSearch:
|
plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||||
|
Loading…
Reference in New Issue
Block a user