Skip to content

Commit

Permalink
Close redirect. Refs #100
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Mar 29, 2022
1 parent fcd4ac5 commit ce82143
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sqlite_web/sqlite_web.py
Expand Up @@ -219,7 +219,10 @@ def table_create():
table = (request.form.get('table_name') or '').strip()
if not table:
flash('Table name is required.', 'danger')
return redirect(request.form.get('redirect') or url_for('index'))
dest = request.form.get('redirect') or url_for('index')
if not dest.startswith('/'):
dest = '/' + dest
return redirect(dest)

dataset[table]
return redirect(url_for('table_import', table=table))
Expand Down
2 changes: 1 addition & 1 deletion sqlite_web/templates/base.html
Expand Up @@ -38,7 +38,7 @@
{% block content_header %}
{% if not dataset.is_readonly %}
<form action="{{ url_for('table_create') }}" class="form-inline float-right" method="post" style="margin-top: 10px;">
<input name="redirect" type="hidden" value="{{ request.path }}" />
<input name="redirect" type="hidden" value="{{ request.full_path }}" />{# full-path begins with "/" and includes querystring #}
<input class="form-control form-control-sm" name="table_name" placeholder="new_table_name" />
<button class="btn btn-primary btn-sm" type="submit">Create</button>
</form>
Expand Down

0 comments on commit ce82143

Please sign in to comment.