Files
guru/dev-python/packageurl/files/safe-for-percent-encoding.patch
bakedsnake 6953e4660b dev-python/packageurl: enable tests
Tests have a  sub-module  dependency,  so  we  must
include   it,	if   the   tests    are    enabled.
Also  adds   pydantic	as   a	 test	dependency.

Adds patches from PR #225 which allows	us  to	use
purl-spec 1.0.0 for testing.
The PR consists of 3 patches, the third of which is
the submodule pin, this third  patch  is  not  used
in favor of pinning via  variable  ${PURL_SPEC_PV}.

Signed-off-by: bakedsnake <bakedsnake@vagrantz.xyz>
2026-11-25 01:22:36 +01:00

30 lines
1.1 KiB
Diff

From 94064987c3fa6bb2e09ad338be1b43efa73b6fa3 Mon Sep 17 00:00:00 2001
From: Yannic Bonenberger <yannic@engflow.com>
Date: Wed, 11 Feb 2026 12:49:47 +0100
Subject: [PATCH 1/3] Use `safe` instead of `.replace()` for percent-encoding
Note that this incorrectly classifies `/` as safe character when
it should be encoded for backward compatibility with the existing test
suite.
It seems like the spec testsuite may be inconsistent whether `/` should be
encoded or not (e.g., Bazel does while Maven doesn't).
---
src/packageurl/__init__.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/packageurl/__init__.py b/src/packageurl/__init__.py
index 3bfae87..cff703c 100644
--- a/src/packageurl/__init__.py
+++ b/src/packageurl/__init__.py
@@ -80,10 +80,9 @@ def quote(s: AnyStr) -> str:
byte or unicode string.
"""
s_bytes = s.encode("utf-8") if isinstance(s, str) else s
- quoted = _percent_quote(s_bytes)
+ quoted = _percent_quote(s_bytes, safe=':')
if not isinstance(quoted, str):
quoted = quoted.decode("utf-8")
- quoted = quoted.replace("%3A", ":")
return quoted