This commit is contained in:
Kovid Goyal 2015-10-10 09:19:13 +05:30
parent d175bd1647
commit 24ffd08b39

View File

@ -6,17 +6,18 @@ from __future__ import (unicode_literals, division, absolute_import,
print_function) print_function)
import errno import errno
from calibre import sanitize_file_name2
from calibre.srv.errors import HTTPNotFound from calibre.srv.errors import HTTPNotFound
from calibre.srv.routes import endpoint from calibre.srv.routes import endpoint
@endpoint('', auth_required=False) @endpoint('', auth_required=False)
def index(ctx, rd): def index(ctx, rd):
return open(P('content-server/index.html'), 'rb') return lopen(P('content-server/index.html'), 'rb')
@endpoint('/js/{which}', auth_required=False) @endpoint('/js/{which}', auth_required=False)
def js(ctx, rd, which): def js(ctx, rd, which):
try: try:
return open(P('content-server/' + which), 'rb') return lopen(P('content-server/' + sanitize_file_name2(which)), 'rb')
except EnvironmentError as e: except EnvironmentError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
raise HTTPNotFound('No js with name: %r' % which) raise HTTPNotFound('No js with name: %r' % which)