Commonly need to verify that file paths provided by a user are really relative and do not refer to locations outside a workspace or the like. Should have something in Util along the lines of
public static boolean isInside(File root, File f) throws IOException { String path = f.getCanonicalPath(); String rootPath = root.getCanonicalPath(); return path.equals(rootPath) || path.startsWith(rootPath + File.separatorChar); }
and a matching method in FilePath.
- relates to
-
JENKINS-44657 Build history not copied after renaming the job's parent folder when using custom build directories
- Resolved