mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
fix: reject trailing newline in collection-name validation
Python's $ anchor matches just before a final newline, so a $-anchored
re.match(r'^[a-zA-Z0-9_-]{1,128}$', name) accepted "papers\n". In local
mode get_or_create_collection() then hit SQLite's CHECK via
INSERT OR IGNORE, silently created no row, and returned a Collection that
failed later on add(). Switch all three duplicated validators (local,
cloud, sqlite backends) to re.fullmatch() so the whole string must match.
This commit is contained in:
parent
e00d360273
commit
91e016d2e4
5 changed files with 26 additions and 5 deletions
|
|
@ -36,6 +36,10 @@ def test_create_duplicate_collection_raises_pageindex_error(storage):
|
|||
@pytest.mark.parametrize("bad_name", [
|
||||
"a/../../etc/passwd", "/etc/passwd", "a$(whoami)", ".hidden",
|
||||
"a b", "válid", "", "a" * 129,
|
||||
# A trailing newline must be rejected: Python's $ matches just before a
|
||||
# final \n, so a $-anchored .match() would let "papers\n" slip through
|
||||
# (then INSERT OR IGNORE silently no-ops on the SQL CHECK).
|
||||
"papers\n", "\npapers", "papers\n\n",
|
||||
])
|
||||
def test_create_collection_rejects_invalid_names_at_the_python_layer(storage, bad_name):
|
||||
"""SQLiteStorage must validate collection names itself — it's a public
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue