From 45b92c86384c600fee0823362f36e8efda832fd3 Mon Sep 17 00:00:00 2001 From: catborise Date: Mon, 19 Oct 2026 16:20:15 +0300 Subject: [PATCH] fix(storages): the pool form in the page no longer refuses paths the server accepts The create pool modals kept their own pattern attributes, older and stricter than the server's check: a logical source took only lower-case letters, digits and "/", dir and NFS paths no "." or ":", and the NFS fields stopped at 40 characters (the form allows 100). The browser refused /dev/mapper/vg0-data, /dev/disk/by-id/wwn-..., /srv/vm.images or /export/vm_images.v2 before the server saw them. The path fields keep "required" and leave the check to the server, which shows its message. --- storages/templates/create_stg_block.html | 10 +++++----- storages/tests/test_pool_target.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/storages/templates/create_stg_block.html b/storages/templates/create_stg_block.html index 4512cc36..c048b0a5 100644 --- a/storages/templates/create_stg_block.html +++ b/storages/templates/create_stg_block.html @@ -62,7 +62,7 @@
- +
@@ -91,7 +91,7 @@
- +
@@ -191,7 +191,7 @@
- +
@@ -208,7 +208,7 @@
- +
@@ -236,7 +236,7 @@
- +
diff --git a/storages/tests/test_pool_target.py b/storages/tests/test_pool_target.py index 47fd2246..03aede82 100644 --- a/storages/tests/test_pool_target.py +++ b/storages/tests/test_pool_target.py @@ -3,8 +3,11 @@ paths of letters, digits and "/", "_", ".", ":" and "-" (not first, not right after "/"): both values go into the pool XML.""" import time +from types import SimpleNamespace +from django.template.loader import render_to_string from django.test import SimpleTestCase +from lxml import html from storages.forms import AddStgPool @@ -60,3 +63,14 @@ class PoolTargetTests(SimpleTestCase): start = time.monotonic() self.assertTrue(target_error("," + "-" * 98 + "!")) self.assertLess(time.monotonic() - start, 1) + + def test_the_create_form_leaves_the_path_check_to_the_server(self): + # a stricter pattern or a shorter maxlength in the page refuses paths the form accepts + superuser = SimpleNamespace(user=SimpleNamespace(is_superuser=True)) + page = html.fromstring(render_to_string("create_stg_block.html", {"request": superuser})) + fields = page.xpath("//input[@name='target' or @name='source']") + self.assertEqual(len(fields), 5) + for field in fields: + with self.subTest(form=field.xpath("string(ancestor::form//input[@name='stg_type']/@value)"), name=field.name): + self.assertIsNone(field.get("pattern")) + self.assertGreaterEqual(int(field.get("maxlength", 100)), 100)