Don't persist _next in hidden field, closes #1483

This commit is contained in:
Simon Willison 2021-10-13 14:08:06 -07:00
commit b50bf5d13f
2 changed files with 11 additions and 1 deletions

View file

@ -889,7 +889,7 @@ class TableView(RowTableShared):
form_hidden_args = []
for key in request.args:
if key.startswith("_") and key not in ("_sort", "_search"):
if key.startswith("_") and key not in ("_sort", "_search", "_next"):
for value in request.args.getlist(key):
form_hidden_args.append((key, value))

View file

@ -563,6 +563,16 @@ def test_facets_persist_through_filter_form(app_client):
]
def test_next_does_not_persist_in_hidden_field(app_client):
response = app_client.get("/fixtures/searchable?_size=1&_next=1")
assert response.status == 200
inputs = Soup(response.body, "html.parser").find("form").findAll("input")
hiddens = [i for i in inputs if i["type"] == "hidden"]
assert [(hidden["name"], hidden["value"]) for hidden in hiddens] == [
("_size", "1"),
]
@pytest.mark.parametrize(
"path,expected_classes",
[