fa416c484061b1e44519962435588916dc14a1f7 markd Wed Dec 9 22:04:07 2020 -0800 added isSafeRelativePath and removed way too low-level verbose logging diff --git src/inc/filePath.h src/inc/filePath.h index 80a4c68..e6fc303 100644 --- src/inc/filePath.h +++ src/inc/filePath.h @@ -25,18 +25,26 @@ * same directory holding the baseFile. * An example of using this would be in processing include * files. In this case the baseFile would be the current * source file, and the relPath would be from the include * statement. The returned result could then be used to * open the include file. */ char *mustPathRelativeToFile(char *baseFile, char *relPath); /* Make Path Relative To File or Abort. */ void undosPath(char *path); /* Convert '\' to '/' in path. (DOS/Windows is typically ok with * this actually.) */ char *makeRelativePath(char *from, char *to); -/* Calculate relative path between two absolute ones */ +/* Calculate a relative path from one absolute directory/file to another. + * Assumptions: both from and to are canonicalized absolute paths beginning + * at "/" or "//". Filenames are okay, but all directory names must end with + * a "/" to distinguish them from files. + * e.g., /test/dir/ is a directory, but /test/dir is a file. + */ + +boolean isSafeRelativePath(char *path); +/* check that path is relative and contains no ".." elements */ #endif /* FILEPATH_H */