]> granicus.if.org Git - neomutt/commitdiff
fix parsing of urls containing '?'
authorRichard Russon <rich@flatcap.org>
Tue, 30 Jan 2018 14:56:46 +0000 (14:56 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 1 Feb 2018 12:08:11 +0000 (12:08 +0000)
The URL schemes come in two patterns
- smtp://user:pass@host
- notmuch:///path?query

The 'host' types don't take a query string.
'notmuch' and 'mailto' don't use a 'user:pass' string.

This fix will still be confused by a notmuch URL that has a '?' in the
path component, but no query string.  (but I don't think the code ever
coped with that).  e.g.

- notmuch:///dir?name/

Fixes #1043

url.c

diff --git a/url.c b/url.c
index d6d9ad12394cf74f175b35946832971388dd18c7..8adea2cab5c51d693868ef3bcb56e88a7be2ef98 100644 (file)
--- a/url.c
+++ b/url.c
@@ -174,12 +174,20 @@ int url_parse(struct Url *u, char *src)
 
   src += 2;
 
-  t = strchr(src, '?');
-  if (t)
+  /* Notmuch and mailto schemes can include a query */
+#ifdef USE_NOTMUCH
+  if ((u->scheme == U_NOTMUCH) || (u->scheme == U_MAILTO))
+#else
+  if (u->scheme == U_MAILTO)
+#endif
   {
-    *t++ = '\0';
-    if (parse_query_string(u, t) < 0)
-      goto err;
+    t = strrchr(src, '?');
+    if (t)
+    {
+      *t++ = '\0';
+      if (parse_query_string(u, t) < 0)
+        goto err;
+    }
   }
 
   u->path = strchr(src, '/');