diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-06-12 14:07:01 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2022-06-12 14:07:16 +0200 |
| commit | e6ca751e92dbd9f42e68dcddee90fc5787f355da (patch) | |
| tree | f10f164a03e16af07fa667bc502dd03509fb9a5e /src | |
| parent | c6516673ee4bc43d779b1852faf970caf5d3ddca (diff) | |
Issue #142: fl_filename_absolute correctly handles trailing "..".
Diffstat (limited to 'src')
| -rw-r--r-- | src/filename_absolute.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx index 4e4e8ff56..41f7f64ee 100644 --- a/src/filename_absolute.cxx +++ b/src/filename_absolute.cxx @@ -69,19 +69,26 @@ int Fl_System_Driver::filename_absolute(char *to, int tolen, const char *from) { return 0; } a = temp+strlen(temp); + /* remove trailing '/' in current working directory */ if (isdirsep(*(a-1))) a--; /* remove intermediate . and .. names: */ while (*start == '.') { - if (start[1]=='.' && isdirsep(start[2])) { + if (start[1]=='.' && (isdirsep(start[2]) || start[2]==0) ) { + // found "..", remove the last directory segment form cwd char *b; for (b = a-1; b >= temp && !isdirsep(*b); b--) {/*empty*/} if (b < temp) break; a = b; - start += 3; + if (start[2]==0) + start += 2; // Skip to end of path + else + start += 3; // Skip over dir separator } else if (isdirsep(start[1])) { + // found "./" in path, just skip it start += 2; } else if (!start[1]) { - start ++; // Skip lone "." + // found "." at end of path, just skip it + start ++; break; } else break; |
