mirror of https://github.com/omar-polo/gmid.git
remove infinite loop
This commit is contained in:
parent
3c1cf9d07c
commit
6a9ae70773
4
iri.c
4
iri.c
|
@ -209,8 +209,8 @@ path_clean(char *path)
|
|||
|
||||
/* 2. eliminate each . path name element */
|
||||
for (i = path; *i; ++i) {
|
||||
if ((i == path || *i == '/') && *(i+1) == '.' &&
|
||||
*(i+2) == '/') {
|
||||
if ((i == path || *i == '/') &&
|
||||
*i != '.' && i[1] == '.' && i[2] == '/') {
|
||||
/* move also the \0 */
|
||||
memmove(i, i+2, strlen(i)-1);
|
||||
i--;
|
||||
|
|
|
@ -153,6 +153,10 @@ main(void)
|
|||
FAIL,
|
||||
empty,
|
||||
"reject paths that would escape the root");
|
||||
TEST("gemini://omarpolo.com/foo/../../",
|
||||
FAIL,
|
||||
empty,
|
||||
"reject paths that would escape the root")
|
||||
TEST("gemini://omarpolo.com/foo/../foo/../././/bar/baz/.././.././/",
|
||||
PASS,
|
||||
IRI("gemini", "omarpolo.com", "", "", "", ""),
|
||||
|
|
Loading…
Reference in New Issue