Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix jinja2 rendering for password protected notebooks #2699

Merged
merged 2 commits into from
Dec 19, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion IPython/frontend/html/notebook/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import uuid
import os

import tornado
from tornado import web
from tornado import websocket

Expand Down Expand Up @@ -225,7 +226,7 @@ class LoginHandler(AuthenticatedHandler):
def _render(self, message=None):
template = self.application.jinja2_env.get_template('login.html')
self.write( template.render(
next=self.get_argument('next', default=self.application.ipython_app.base_project_url),
next=tornado.escape.url_escape(self.get_argument('next', default=self.application.ipython_app.base_project_url)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tornado.escape is only available here because importing web and websocket imports escape, whereas doing just import tornado does not. We should be explicit and either import tornado.escape or from tornado.escape import url_escape

read_only=self.read_only,
logged_in=self.logged_in,
login_available=self.login_available,
Expand Down
18 changes: 9 additions & 9 deletions IPython/frontend/html/notebook/templates/login.html
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{% extends page.html %}
{% extends "page.html" %}

{% block stylesheet %}

<link rel="stylesheet" href="{{static_url("css/login.css") }}" type="text/css"/>

{% end %}
{% endblock %}


{% block login_widget %}
{% end %}
{% endblock %}


{% block site %}

<div id="main_app">

{% if login_available %}
<form action="{{base_project_url}}login?next={{url_escape(next)}}" method="post">
<form action="{{base_project_url}}login?next={{next}}" method="post">
Password: <input type="password" class='ui-widget ui-widget-content' name="password" id="password_input">
<input type="submit" value="Log in" id="login_submit">
</form>
{% end %}
{% endif %}

{% if message %}
{% for key in message %}
<div class="message {{key}}">
{{message[key]}}
</div>
{% end %}
{% end %}
{% endfor %}
{% endif %}

<div/>

{% end %}
{% endblock %}


{% block script %}

<script src="{{static_url("js/loginmain.js") }}" type="text/javascript" charset="utf-8"></script>

{% end %}
{% endblock %}
16 changes: 8 additions & 8 deletions IPython/frontend/html/notebook/templates/logout.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{% extends page.html %}
{% extends "page.html" %}

{% block stylesheet %}

<link rel="stylesheet" href="{{static_url("css/logout.css") }}" type="text/css"/>

{% end %}
{% endblock %}


{% block login_widget %}
{% end %}
{% endblock %}

{% block site %}

Expand All @@ -19,22 +19,22 @@
<div class="message {{key}}">
{{message[key]}}
</div>
{% end %}
{% end %}
{% endfor %}
{% endif %}

{% if read_only or not login_available %}
Proceed to the <a href="{{base_project_url}}">dashboard</a>.
{% else %}
Proceed to the <a href="{{base_project_url}}login">login page</a>.
{% end %}
{% endif %}


<div/>

{% end %}
{% endblock %}

{% block script %}

<script src="{{static_url("js/logoutmain.js") }}" type="text/javascript" charset="utf-8"></script>

{% end %}
{% endblock %}