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
-
Code changed in jenkins
User: Jesse Glick
Path:
cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java
http://jenkins-ci.org/commit/workflow-plugin/c6b0c9fa4362b9f8d0903fdc0b46258f465e7210
Log:
JENKINS-26838 Noting.