AmendHub

Download:

jcs

/

detritus

/

amendments

/

16

main: Put slash in path when parsing URIs


jcs made amendment 16 about 1 year ago
--- main.c Fri Oct 25 21:50:14 2024 +++ main.c Mon Oct 28 09:36:29 2024 @@ -244,9 +244,9 @@ generic_parse_uri(char *protocol, char *uristr) /* protocol://host/path */ if (count = 0, sscanf(uristr, - "%" STR(URI_PROTOCOL_LEN) "[^:]://%" STR(URI_HOSTNAME_LEN) "[^/]/%" + "%" STR(URI_PROTOCOL_LEN) "[^:]://%" STR(URI_HOSTNAME_LEN) "[^/]%" STR(URI_PATH_LEN) "s%n", - &uri->protocol, &uri->hostname, &uri->path + 1, &count) == 3 && + &uri->protocol, &uri->hostname, &uri->path, &count) == 3 && count > 10) goto parse_ok; @@ -254,7 +254,8 @@ generic_parse_uri(char *protocol, char *uristr) if (count = 0, sscanf(uristr, "%" STR(URI_PROTOCOL_LEN) "[^:]://%" STR(URI_HOSTNAME_LEN) "[^/]/%n", &uri->protocol, &uri->hostname, &count) == 2 && count > 10) { - snprintf(uri->path, sizeof(uri->path), "/"); + uri->path[0] = '/'; + uri->path[1] = '\0'; goto parse_ok; } @@ -262,7 +263,8 @@ generic_parse_uri(char *protocol, char *uristr) if (count = 0, sscanf(uristr, "%" STR(URI_PROTOCOL_LEN) "[^:]://%" STR(URI_HOSTNAME_LEN) "[^/]%n", &uri->protocol, &uri->hostname, &count) == 2 && count > 10) { - snprintf(uri->path, sizeof(uri->path), "/"); + uri->path[0] = '/'; + uri->path[1] = '\0'; goto parse_ok; }