aboutsummaryrefslogtreecommitdiff
path: root/uri.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-10-23 06:47:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-10-23 06:47:21 +0000
commitd68da27a7f869cb3c66d0e0b52c5559f1ceb3d3b (patch)
tree950718b739a2693d331573ff238b943e375a0486 /uri.c
parentRevert "url-mode: don't strip the file:// prefix from localhost URIs" (diff)
uri: skip query/fragment parsing when dealing with file:// URIs
Also, ignore invalid query/fragments (i.e. if the fragment comes before the query). Closes #1840
Diffstat (limited to 'uri.c')
-rw-r--r--uri.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/uri.c b/uri.c
index 4de4bd88..e09f7a97 100644
--- a/uri.c
+++ b/uri.c
@@ -144,6 +144,21 @@ uri_parse(const char *uri, size_t len,
const char *query_start = memchr(start, '?', left);
const char *fragment_start = memchr(start, '#', left);
+ if (streq(*scheme, "file")) {
+ /* Don't try to parse query/fragment in file URIs, just treat
+ the remaining text as path */
+ query_start = NULL;
+ fragment_start = NULL;
+ }
+
+ else if (query_start != NULL && fragment_start != NULL &&
+ fragment_start < query_start)
+ {
+ /* Invalid URI - for now, ignore, and treat is as part of path */
+ query_start = NULL;
+ fragment_start = NULL;
+ }
+
size_t path_len =
query_start != NULL ? query_start - start :
fragment_start != NULL ? fragment_start - start :