Content server: Fix a regression in the previous release that broke viewing math ebooks in the browser viewer. Fixes #1810884 [recent changes to mathjax broke server](https://bugs.launchpad.net/calibre/+bug/1810884)

This commit is contained in:
Kovid Goyal 2019-01-17 09:25:55 +05:30
parent 473bff43e3
commit 64ad30d910
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 8 deletions

View File

@ -244,7 +244,7 @@ def mathjax(ctx, rd, which):
return rd.etagged_dynamic_response(manifest['etag'], manifest_as_json, content_type='application/json; charset=UTF-8') return rd.etagged_dynamic_response(manifest['etag'], manifest_as_json, content_type='application/json; charset=UTF-8')
if which not in manifest['files']: if which not in manifest['files']:
raise HTTPNotFound('No MathJax file named: %s' % which) raise HTTPNotFound('No MathJax file named: %s' % which)
path = os.path.abspath(os.path.join(rd.tdir, 'mathjax', which)) path = os.path.abspath(P('mathjax/' + which, allow_user_override=False))
if not path.startswith(rd.tdir): if not path.startswith(P('mathjax', allow_user_override=False)):
raise HTTPNotFound('No MathJax file named: %s' % which) raise HTTPNotFound('No MathJax file named: %s' % which)
return rd.filesystem_file_with_constant_etag(lopen(path, 'rb'), manifest['etag']) return rd.filesystem_file_with_constant_etag(lopen(path, 'rb'), manifest['etag'])

View File

@ -211,12 +211,7 @@ def compile_srv():
rb = os.path.join(base, 'src', 'calibre', 'srv', 'render_book.py') rb = os.path.join(base, 'src', 'calibre', 'srv', 'render_book.py')
with lopen(rb, 'rb') as f: with lopen(rb, 'rb') as f:
rv = str(int(re.search(br'^RENDER_VERSION\s+=\s+(\d+)', f.read(), re.M).group(1))) rv = str(int(re.search(br'^RENDER_VERSION\s+=\s+(\d+)', f.read(), re.M).group(1)))
try: mathjax_version = json.loads(P('mathjax/manifest.json', data=True, allow_user_override=False))['etag']
mathjax_version = P('content-server/mathjax.version', data=True, allow_user_override=False).decode('utf-8')
except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
mathjax_version = '0'
base = os.path.join(base, 'resources', 'content-server') base = os.path.join(base, 'resources', 'content-server')
fname = os.path.join(rapydscript_dir, 'srv.pyj') fname = os.path.join(rapydscript_dir, 'srv.pyj')
with lopen(fname, 'rb') as f: with lopen(fname, 'rb') as f: