mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Fix viewing HTML in sandboxed iframe
See gh-2203 The URL calculation was going wrong, so it was using a URL starting with //files. This uses url_path_join() to get the separators right.
This commit is contained in:
parent
c305d8fda3
commit
f384662df4
@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<iframe id="iframe" sandbox="allow-scripts" src="{{base_url}}/files/{{file_path}}"></iframe>
|
<iframe id="iframe" sandbox="allow-scripts" src="{{file_url}}"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
from tornado import web
|
from tornado import web
|
||||||
from ..base.handlers import IPythonHandler, path_regex
|
from ..base.handlers import IPythonHandler, path_regex
|
||||||
from ..utils import url_escape
|
from ..utils import url_escape, url_path_join
|
||||||
|
|
||||||
class ViewHandler(IPythonHandler):
|
class ViewHandler(IPythonHandler):
|
||||||
"""Render HTML files within an iframe."""
|
"""Render HTML files within an iframe."""
|
||||||
@ -17,8 +17,9 @@ class ViewHandler(IPythonHandler):
|
|||||||
raise web.HTTPError(404, u'File does not exist: %s' % path)
|
raise web.HTTPError(404, u'File does not exist: %s' % path)
|
||||||
|
|
||||||
basename = path.rsplit('/', 1)[-1]
|
basename = path.rsplit('/', 1)[-1]
|
||||||
|
file_url = url_path_join(self.base_url, 'files', path)
|
||||||
self.write(
|
self.write(
|
||||||
self.render_template('view.html', file_path=url_escape(path), page_title=basename)
|
self.render_template('view.html', file_url=file_url, page_title=basename)
|
||||||
)
|
)
|
||||||
|
|
||||||
default_handlers = [
|
default_handlers = [
|
||||||
|
Loading…
Reference in New Issue
Block a user