From 7e73d98c3e95431b04eb21a4e4e3dec20cfe4eee Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Mon, 18 Mar 2024 20:45:47 +0000 Subject: [PATCH] Normalize dynamic values --- warehouse/forklift/legacy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py index 5e7bf938e1ce..3dda986d32d8 100644 --- a/warehouse/forklift/legacy.py +++ b/warehouse/forklift/legacy.py @@ -710,6 +710,11 @@ def file_upload(request): # this and store this as a list. keywords=", ".join(meta.keywords) if meta.keywords else None, requires_python=str(meta.requires_python) if meta.requires_python else None, + # Since dynamic field values are RFC 822 email headers, which are + # case-insensitive, normalize them to title-case so we don't have + # to store every possible variation, and can use an enum to restrict them + # in the database + dynamic=[x.title() for x in meta.dynamic] if meta.dynamic else None, **{ k: getattr(meta, k) for k in { @@ -723,7 +728,6 @@ def file_upload(request): "maintainer_email", "home_page", "download_url", - "dynamic", "provides_extra", } },