Merge branch 'wip/chergert/RFC-1123' into 'main'

glib/gconvert: allow domain names starting with digit

Closes #3523 and chergert/ptyxis#490

See merge request GNOME/glib!4892
This commit is contained in:
Marco Trevisan
2025-10-30 04:48:11 +01:00
2 changed files with 5 additions and 8 deletions

View File

@@ -1518,18 +1518,13 @@ is_asciialphanum (gunichar c)
return c <= 0x7F && g_ascii_isalnum (c);
}
static gboolean
is_asciialpha (gunichar c)
{
return c <= 0x7F && g_ascii_isalpha (c);
}
/* allows an empty string */
static gboolean
hostname_validate (const char *hostname)
{
const char *p;
gunichar c, first_char, last_char;
gboolean no_domain = TRUE;
p = hostname;
if (*p == '\0')
@@ -1554,7 +1549,8 @@ hostname_validate (const char *hostname)
/* if that was the last label, check that it was a toplabel */
if (c == '\0' || (c == '.' && *p == '\0'))
return is_asciialpha (first_char);
return no_domain || is_asciialphanum (first_char);
no_domain = FALSE;
}
while (c == '.');
return FALSE;

View File

@@ -154,7 +154,8 @@ file_from_uri_tests[] = {
{ "file:///c:/foo", "/c:/foo", NULL, 0 },
{ "file:////c:/foo", "//c:/foo", NULL, 0 },
#endif
{ "file://0123456789/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
{ "file://0123456789/", "/", "0123456789", 0},
{ "file://dev-1.2/", "/", "dev-1.2", 0},
{ "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/", "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0 },
{ "file://abcdefghijklmnopqrstuvwxyz/", "/", "abcdefghijklmnopqrstuvwxyz", 0 },
{ "file://-_.!~*'()/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},