diff options
author | Omar Polo <op@omarpolo.com> | 2020-11-06 14:24:25 +0100 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2020-11-06 14:24:25 +0100 |
commit | 3c19febb014ddc7d9afa1b517c108da4b3fda5dc (patch) | |
tree | eb81372ab81188fb74d8001be53e852eabc8f8b2 /gmid.c | |
parent | e8cac16e03c5b86eebd6e50b267a3f0479bf3a81 (diff) |
ensure the requested protocol is “gemini”
…and not something else that happens to be 6-bytes long.
Diffstat (limited to 'gmid.c')
-rw-r--r-- | gmid.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -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); |