mirror of https://github.com/omar-polo/gmid.git
ensure the requested protocol is “gemini”
…and not something else that happens to be 6-bytes long.
This commit is contained in:
parent
e8cac16e03
commit
3c19febb01
|
@ -1,3 +1,8 @@
|
|||
2020-11-06 Omar Polo <op@omarpolo.com>
|
||||
|
||||
* gmid.c (url_after_proto): ensure that the requested protocol is
|
||||
“gemini” and not something else that’s long 6 bytes.
|
||||
|
||||
2020-11-06 Omar Polo <op@venera>
|
||||
|
||||
* gmid.1: added option to log to a file
|
||||
|
|
13
gmid.c
13
gmid.c
|
@ -141,17 +141,18 @@ url_after_proto(char *url)
|
|||
char *s;
|
||||
const char *proto = "gemini";
|
||||
const char *marker = "://";
|
||||
size_t i;
|
||||
|
||||
/* a relative URL */
|
||||
if ((s = strstr(url, marker)) == NULL)
|
||||
return url;
|
||||
|
||||
/* not a gemini:// URL */
|
||||
|
||||
if (s - strlen(proto) < url)
|
||||
if (s - strlen(proto) != url)
|
||||
return NULL;
|
||||
/* TODO: */
|
||||
/* if (strcmp(s - strlen(proto), proto)) */
|
||||
/* return NULL; */
|
||||
|
||||
for (i = 0; proto[i] != '\0'; ++i)
|
||||
if (url[i] != proto[i])
|
||||
return NULL;
|
||||
|
||||
/* a valid gemini:// URL */
|
||||
return s + strlen(marker);
|
||||
|
|
Loading…
Reference in New Issue