commit 42bbdc7978acc6be9beb5baa7d94fedb7c211b49 from: Omar Polo date: Thu Jan 21 22:48:16 2021 UTC trim initial forward slashes this parse gemini://example.com///foo into an IRI whose path is "foo". I'm not 100% this is standard-compliant but: 1. it seems a logical consequence of the URI/IRI cleaning algo (where we drop sequential slashes) 2. practically speaking serving file a sequence of forward slashes doesn't really make sense, even in the case of CGI scripts commit - f77a8c867ecc2881d60345b9e1b1ee4259189e9a commit + 42bbdc7978acc6be9beb5baa7d94fedb7c211b49 blob - 26ee920fc2c12088c713411c936ddd22c5b92749 blob + beba36872d89965202880fa3660a2cb55a581e10 --- iri.c +++ iri.c @@ -292,6 +292,10 @@ static int parse_path(struct parser *p) { char c; + + /* trim initial slashes */ + while (*p->iri == '/') + p->iri++; p->parsed->path = p->iri; if (*p->iri == '\0') { blob - 81ec0b4d26a7ef7cae39b770bcd0cbb54bfc3c6c blob + 03c547a2e7cbc5e26c46aa25c177be72ba8b6579 --- iri_test.c +++ iri_test.c @@ -169,6 +169,14 @@ main(void) PASS, IRI("gemini", "omarpolo.com", "", "", "", ""), "parse path with lots of cleaning available"); + TEST("gemini://omarpolo.com//foo", + PASS, + IRI("gemini", "omarpolo.com", "", "foo", "", ""), + "Trim initial slashes"); + TEST("gemini://omarpolo.com/////foo", + PASS, + IRI("gemini", "omarpolo.com", "", "foo", "", ""), + "Trim initial slashes (pt. 2)"); /* query */ TEST("foo://example.com/foo/?gne",