Content server: Fix next and previous links not working in the mobile view when using a search query that includes url unsafe characters. Fixes #1519606 [In Content Server mobile view, 'Next' URL is not formed correctly when search query contains user tag](https://bugs.launchpad.net/calibre/+bug/1519606)

This commit is contained in:
Kovid Goyal 2015-11-25 10:51:23 +05:30
parent a90c68d8e9
commit cac806b417

View File

@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import re, os import re, os
import __builtin__ import __builtin__
from urllib import quote from urllib import quote, urlencode
import cherrypy import cherrypy
from lxml import html from lxml import html
@ -224,6 +224,7 @@ class MobileServer(object):
num = int(num) num = int(num)
except ValueError: except ValueError:
raise cherrypy.HTTPError(400, 'num: %s is not an integer'%num) raise cherrypy.HTTPError(400, 'num: %s is not an integer'%num)
print(111111, search)
if not search: if not search:
search = '' search = ''
if isbytestring(search): if isbytestring(search):
@ -287,7 +288,8 @@ class MobileServer(object):
cherrypy.response.headers['Content-Type'] = 'text/html; charset=utf-8' cherrypy.response.headers['Content-Type'] = 'text/html; charset=utf-8'
cherrypy.response.headers['Last-Modified'] = self.last_modified(updated) cherrypy.response.headers['Last-Modified'] = self.last_modified(updated)
url_base = "/mobile?search=" + search+";order="+order+";sort="+sort+";num="+str(num) q = {b'search':search.encode('utf-8'), 'order':order.encode('utf-8'), 'sort':sort.encode('utf-8'), 'num':str(num).encode('utf-8')}
url_base = "/mobile?" + urlencode(q)
ua = cherrypy.request.headers.get('User-Agent', '').strip() ua = cherrypy.request.headers.get('User-Agent', '').strip()
have_kobo_browser = self.is_kobo_browser(ua) have_kobo_browser = self.is_kobo_browser(ua)