From 64ad30d9100194522d35a77acc8784da44f10020 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 17 Jan 2019 09:25:55 +0530 Subject: [PATCH] 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) --- src/calibre/srv/books.py | 4 ++-- src/calibre/utils/rapydscript.py | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/calibre/srv/books.py b/src/calibre/srv/books.py index eb59b425d7..db4567f53d 100644 --- a/src/calibre/srv/books.py +++ b/src/calibre/srv/books.py @@ -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') if which not in manifest['files']: raise HTTPNotFound('No MathJax file named: %s' % which) - path = os.path.abspath(os.path.join(rd.tdir, 'mathjax', which)) - if not path.startswith(rd.tdir): + path = os.path.abspath(P('mathjax/' + which, allow_user_override=False)) + if not path.startswith(P('mathjax', allow_user_override=False)): raise HTTPNotFound('No MathJax file named: %s' % which) return rd.filesystem_file_with_constant_etag(lopen(path, 'rb'), manifest['etag']) diff --git a/src/calibre/utils/rapydscript.py b/src/calibre/utils/rapydscript.py index 8c7bfc5f1c..946be0f5a4 100644 --- a/src/calibre/utils/rapydscript.py +++ b/src/calibre/utils/rapydscript.py @@ -211,12 +211,7 @@ def compile_srv(): rb = os.path.join(base, 'src', 'calibre', 'srv', 'render_book.py') with lopen(rb, 'rb') as f: rv = str(int(re.search(br'^RENDER_VERSION\s+=\s+(\d+)', f.read(), re.M).group(1))) - try: - 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' + mathjax_version = json.loads(P('mathjax/manifest.json', data=True, allow_user_override=False))['etag'] base = os.path.join(base, 'resources', 'content-server') fname = os.path.join(rapydscript_dir, 'srv.pyj') with lopen(fname, 'rb') as f: