b50cddd
From 05848bb3cb10ea19ef8cba607bdabcd25560063c Mon Sep 17 00:00:00 2001
b50cddd
From: Felipe Contreras <felipe.contreras@gmail.com>
b50cddd
Date: Sun, 19 May 2013 03:50:01 +0000
b50cddd
Subject: Fix exo_str_looks_like_an_uri() (bug #10098).
b50cddd
b50cddd
Commit d11199b (Check if uris also contain a slash (bug #9244)) tried to
b50cddd
fix a hang in thunar by properly recognizing that 'http:' is not an URI,
b50cddd
however, while doing so, it broke proper URIs like 'magnet:foo'.
b50cddd
b50cddd
As the RFC clearly states:
b50cddd
b50cddd
   The following are two example URIs and their component parts:
b50cddd
b50cddd
         foo://example.com:8042/over/there?name=ferret#nose
b50cddd
         \_/   \______________/\_________/ \_________/ \__/
b50cddd
          |           |            |            |        |
b50cddd
       scheme     authority       path        query   fragment
b50cddd
          |   _____________________|__
b50cddd
         / \ /                        \
b50cddd
         urn:example:animal:ferret:nose
b50cddd
b50cddd
But even with this succinct example exo_str_looks_like_an_uri() fails.
b50cddd
b50cddd
There is an easy solution; fail only when component part is missing
b50cddd
('urn:'), but succeed otherwise.
b50cddd
b50cddd
This solution fixes 'magnet:foo', and doesn't break the current
b50cddd
expectation from thunar that 'http:' should fail, having the best of
b50cddd
both worlds.
b50cddd
b50cddd
[1] http://www.ietf.org/rfc/rfc3986.txt
b50cddd
b50cddd
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
b50cddd
---
b50cddd
diff --git a/exo/exo-string.c b/exo/exo-string.c
b50cddd
index 33f86f9..056b36a 100644
b50cddd
--- a/exo/exo-string.c
b50cddd
+++ b/exo/exo-string.c
b50cddd
@@ -429,7 +429,7 @@ exo_str_looks_like_an_uri (const gchar *str)
b50cddd
       for (++s; g_ascii_isalnum (*s) || *s == '+' || *s == '-' || *s == '.'; ++s);
b50cddd
 
b50cddd
       /* <scheme> must be followed by ":" */
b50cddd
-      return (*s == ':' && *(s+1) == '/');
b50cddd
+      return (*s == ':' && *(s+1) != '\0');
b50cddd
     }
b50cddd
 
b50cddd
   return FALSE;
b50cddd
--
b50cddd
cgit v0.9.2