diff -r 060a8cda7f62 -r 2f85df8cd35e libidav/utils.c --- a/libidav/utils.c Thu Mar 28 11:54:27 2019 +0100 +++ b/libidav/utils.c Thu Mar 28 14:18:54 2019 +0100 @@ -370,6 +370,34 @@ return sbuffer.length; } +int util_path_isrelated(const char *path1, const char *path2) { + scstr_t p1 = scstr(path1); + scstr_t p2 = scstr(path2); + + if(p1.ptr[p1.length-1] == '/') { + p1.length--; + } + if(p2.ptr[p2.length-1] == '/') { + p2.length--; + } + + if(p2.length < p1.length) { + return 0; + } + + if(!sstrcmp(p1, p2)) { + return 1; + } + + if(sstrprefix(p2, p1)) { + if(p2.ptr[p1.length] == '/') { + return 1; + } + } + + return 0; +} + void util_capture_header(CURL *handle, UcxMap* map) { if(map) { curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, util_header_callback);