From 0c58d181572f43c242505d9e7b7f454b37e122ac Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Mon, 4 Aug 2025 15:04:03 -0400 Subject: [PATCH] fix(admin): strip whitespace from value Humans can make mistakes in a rename, strip the input prior to persisting. Fixes WAREHOUSE-PRODUCTION-2A1 Signed-off-by: Mike Fiedler --- tests/unit/admin/views/test_organizations.py | 2 +- warehouse/admin/views/organizations.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/admin/views/test_organizations.py b/tests/unit/admin/views/test_organizations.py index 190f6be8c765..cdc1c7bdd411 100644 --- a/tests/unit/admin/views/test_organizations.py +++ b/tests/unit/admin/views/test_organizations.py @@ -566,7 +566,7 @@ def test_rename(self, db_request): db_request.matchdict = {"organization_id": organization.id} db_request.params = { - "new_organization_name": "widget", + "new_organization_name": " widget ", # Test trimming whitespace } db_request.user = admin db_request.route_path = pretend.call_recorder(_organization_application_routes) diff --git a/warehouse/admin/views/organizations.py b/warehouse/admin/views/organizations.py index 667a9e54af83..578c23c521b8 100644 --- a/warehouse/admin/views/organizations.py +++ b/warehouse/admin/views/organizations.py @@ -272,7 +272,7 @@ def organization_rename(request): raise HTTPNotFound old_organization_name = organization.name - new_organization_name = request.params.get("new_organization_name") + new_organization_name = request.params.get("new_organization_name").strip() try: organization_service.rename_organization(organization_id, new_organization_name)