Handle databases with spaces in their names

This commit is contained in:
Simon Willison 2019-07-22 18:00:07 -07:00
commit 4fdbeb4924
3 changed files with 13 additions and 0 deletions

View file

@ -203,6 +203,8 @@ class DataView(BaseView):
hash = None
else:
name = db_name
if "%" in name:
name = urllib.parse.unquote_plus(name)
# Verify the hash
try:
db = self.ds.databases[name]

View file

@ -215,6 +215,11 @@ def app_client_with_dot():
yield from make_app_client(filename="fixtures.dot.db")
@pytest.fixture(scope="session")
def app_client_with_space():
yield from make_app_client(filename="fixtures with space.db")
@pytest.fixture(scope="session")
def app_client_with_cors():
yield from make_app_client(cors=True)

View file

@ -9,6 +9,7 @@ from .fixtures import ( # noqa
app_client_two_attached_databases_one_immutable,
app_client_with_cors,
app_client_with_dot,
app_client_with_space,
generate_compound_rows,
generate_sortable_rows,
make_app_client,
@ -544,6 +545,11 @@ def test_database_page_for_database_with_dot_in_name(app_client_with_dot):
assert 200 == response.status
def test_database_page_for_database_with_space_in_name(app_client_with_space):
response = app_client_with_space.get("/fixtures%20with%20space.json")
assert 200 == response.status
def test_custom_sql(app_client):
response = app_client.get(
"/fixtures.json?sql=select+content+from+simple_primary_key&_shape=objects"