commit cb7621af57ac2abad12fa61893d00199daebdd29 from: Omar Polo date: Sat Dec 24 22:26:06 2022 UTC iri: fix remove_dot_segments algorithm i've misread the description in the RFC; we should copy up to, but not including, the next '/' at the end and manually inject some '/' in some other cases. commit - a9eac73439353c3222a01235919b74a0ba6dc483 commit + cb7621af57ac2abad12fa61893d00199daebdd29 blob - 7b39d540f66998f673301046b1865c41164bc0d0 blob + 362ed324bf60c6a99a1d6f2c6ab318910bbaf212 --- iri.c +++ iri.c @@ -498,6 +498,7 @@ remove_dot_segments(struct iri *iri) continue; } if (!strcmp(p, "/.")) { + *q++ = '/'; p += 2; break; } @@ -507,6 +508,7 @@ remove_dot_segments(struct iri *iri) p += 3; while (q != buf && *--q != '/') continue; + *q++ = '/'; continue; } /* D */ @@ -519,8 +521,7 @@ remove_dot_segments(struct iri *iri) break; } /* E */ - if ((s = strchr(p + 1, '/')) != NULL) - s++; + s = strchr(p + 1, '/'); while (*p && p != s && (q - buf < bufsize)) *q++ = *p++; }