diff mbox series

[2/2] tests/fetch: Verify regular expression "URLs" that contain a ?

Message ID 20250228231501.3905069-2-pkj@axis.com
State Accepted, archived
Commit 5af7fe4473cd7e75d4eb7f8b93c499bd157ff156
Headers show
Series [1/2] fetch2: Revert decodeurl() to not use the URI class | expand

Commit Message

Peter Kjellerstedt Feb. 28, 2025, 11:15 p.m. UTC
A regular expression "URL" as used in PREMIRRORS and MIRRORS may contain
a ? as part of the regular expression. Make sure this does not cause
problems when parsed by the fetcher.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 bitbake/lib/bb/tests/fetch.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 48b9e4af16..be09a2964c 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -525,8 +525,7 @@  class MirrorUriTest(FetcherTest):
 
     mirrorvar = "http://.*/.* file:///somepath/downloads/ " \
                 "git://someserver.org/bitbake git://git.openembedded.org/bitbake " \
-                "https://.*/.* file:///someotherpath/downloads/ " \
-                "http://.*/.* file:///someotherpath/downloads/ " \
+                "https?://.*/.* file:///someotherpath/downloads/ " \
                 "svn://svn.server1.com/ svn://svn.server2.com/"
 
     def test_urireplace(self):
@@ -1415,12 +1414,17 @@  class URLHandle(unittest.TestCase):
        "https://somesite.com/somerepo.git;user=anyUser:idtoken=1234" : ('https', 'somesite.com', '/somerepo.git', '', '', {'user': 'anyUser:idtoken=1234'}),
        'git://s.o-me_ONE:%s@git.openembedded.org/bitbake;branch=main;protocol=https' % password: ('git', 'git.openembedded.org', '/bitbake', 's.o-me_ONE', password, {'branch': 'main', 'protocol' : 'https'}),
     }
-    # we require a pathname to encodeurl but users can still pass such urls to 
-    # decodeurl and we need to handle them
+    # We require a pathname to encodeurl but users can still pass URLs without
+    # a path to decodeurl and we need to handle them. decodeurl is also used to
+    # split the regular expression "URLs" that are used in PREMIRRORS and
+    # MIRRORS.
     decodedata = datatable.copy()
     decodedata.update({
        "http://somesite.net;someparam=1": ('http', 'somesite.net', '/', '', '', {'someparam': '1'}),
        "npmsw://some.registry.url;package=@pkg;version=latest": ('npmsw', 'some.registry.url', '/', '', '', {'package': '@pkg', 'version': 'latest'}),
+       r"git://.*/.*": ("git", ".*", "/.*", "", "", {}),
+       r"https?://.*/.*": ("https?", ".*", "/.*", "", "", {}),
+       r"git://(?!internal\.git\.server).*/.*": ("git", r"(?!internal\.git\.server).*", "/.*", "", "", {}),
     })
 
     def test_decodeurl(self):