[glib: 12/13] guri: add some IPv6 scope-id tests




commit 0fea3d71e43ea624b7b44dc02c10d165358b3c68
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Tue Jul 7 20:23:36 2020 +0400

    guri: add some IPv6 scope-id tests
    
    Add a few ipv6 scope parsing corner test cases.
    
    - checking incorrect scoped IPv6 ending with only %25 isn't decoded.
    - checking valid scoped IPv6 is passing g_uri_is_valid()
    
    As discussed in
    https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1567#note_860499,
    for historical reasons, GUri accepts the % preceding the zone-id in the
    unescaped form as well.
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 glib/tests/uri.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/glib/tests/uri.c b/glib/tests/uri.c
index be70b5d6a..dd6933603 100644
--- a/glib/tests/uri.c
+++ b/glib/tests/uri.c
@@ -703,6 +703,8 @@ static const UriAbsoluteTest absolute_tests[] = {
     { "http", NULL, "fe80::dead:beef%em1", -1, "/", NULL, NULL } },
   { "http://[fe80::dead:beef%10]/";,
     { "http", NULL, "fe80::dead:beef%10", -1, "/", NULL, NULL } },
+  { "http://[fe80::dead:beef%25]/";,
+    { "http", NULL, "fe80::dead:beef%25", -1, "/", NULL, NULL } },
 };
 static int num_absolute_tests = G_N_ELEMENTS (absolute_tests);
 
@@ -1275,6 +1277,7 @@ test_uri_is_valid (void)
   g_assert_error (error, G_URI_ERROR, G_URI_ERROR_BAD_HOST);
   g_clear_error (&error);
 
+  g_assert_true (g_uri_is_valid ("http://[fe80::dead:beef%25wef]/";, G_URI_FLAGS_NONE, NULL));
   g_assert_false (g_uri_is_valid ("http://[fe80::dead:beef%wef%]/";, G_URI_FLAGS_NONE, &error));
   g_assert_error (error, G_URI_ERROR, G_URI_ERROR_BAD_HOST);
   g_clear_error (&error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]