summaryrefslogtreecommitdiff
path: root/src/bin/utils.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2016-11-06 19:47:42 +0100
committerBoris Faure <billiob@gmail.com>2016-11-06 20:04:02 +0100
commita977c2d32e4e2b5554c8d7606912d4985ad650e4 (patch)
treed54891bbbd84bf4b394769ca0184664db15fa510 /src/bin/utils.c
parent0cbaaeec9d991ca41576b780dbb1564707bc3a8d (diff)
rewrite link_is_protocol() to handle almost any URI
Diffstat (limited to 'src/bin/utils.c')
-rw-r--r--src/bin/utils.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/bin/utils.c b/src/bin/utils.c
index 1bff81d..57cdb1e 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -121,13 +121,27 @@ homedir_get(char *buf, size_t size)
121Eina_Bool 121Eina_Bool
122link_is_protocol(const char *str) 122link_is_protocol(const char *str)
123{ 123{
124 if (casestartswith(str, "http://") || 124 const char *p = str;
125 casestartswith(str, "https://") || 125 int c = *p;
126 casestartswith(str, "ftp://") || 126
127 casestartswith(str, "file://") || 127 if (!isalpha(c))
128 casestartswith(str, "mailto:")) 128 return EINA_FALSE;
129 return EINA_TRUE; 129
130 return EINA_FALSE; 130 /* Try to follow RFC3986 a bit
131 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
132 * hier-part = "//" authority path-abempty
133 * [...] other stuff not taken into account
134 * scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
135 */
136
137 do
138 {
139 p++;
140 c = *p;
141 }
142 while (isalpha(c) || (c == '.') || (c == '-') || (c == '+'));
143
144 return (p[0] == ':') && (p[1] == '/') && (p[2] == '/');
131} 145}
132 146
133Eina_Bool 147Eina_Bool