Source:
public Boolean invoke(@Nonnull File parentFile, @Nonnull VirtualChannel channel) throws IOException, InterruptedException { if (new File(potentialChildRelativePath).isAbsolute()) { throw new IllegalArgumentException("Only a relative path is supported, the given path is absolute: " + potentialChildRelativePath); } Path parentAbsolutePath = Util.fileToPath(parentFile.getAbsoluteFile()); Path parentRealPath; try { parentRealPath = parentAbsolutePath.toRealPath(); } catch(NoSuchFileException e) { throw new IllegalArgumentException("The parent does not exist"); } String remainingPath = potentialChildRelativePath; Path currentFilePath = parentFile.toPath(); while (!remainingPath.isEmpty()) { Path directChild = this.getDirectChild(currentFilePath, remainingPath); Path childUsingFullPath = currentFilePath.resolve(remainingPath); String childUsingFullPathAbs = childUsingFullPath.toAbsolutePath().toString(); String directChildAbs = directChild.toAbsolutePath().toString(); if (childUsingFullPathAbs.length() == directChildAbs.length()) { remainingPath = ""; } else { remainingPath = childUsingFullPathAbs.substring(directChildAbs.length() + 1); } File childFileSymbolic = Util.resolveSymlinkToFile(directChild.toFile()); if (childFileSymbolic == null) { currentFilePath = directChild; } else { currentFilePath = childFileSymbolic.toPath(); } Path currentFileAbsolutePath = currentFilePath.toAbsolutePath(); try{ Path child = currentFileAbsolutePath.toRealPath(); if (!child.startsWith(parentRealPath)) { return false; } } catch (NoSuchFileException e) { try { Path child = currentFileAbsolutePath.normalize(); Path parent = parentAbsolutePath.normalize(); return child.startsWith(parent); } catch (InvalidPathException e2) { throw new IOException(e2); } } } return true; }

Target:
public Boolean invoke(@Nonnull File parentFile, @Nonnull VirtualChannel channel) throws IOException, InterruptedException { if (new File(potentialChildRelativePath).isAbsolute()) { throw new IllegalArgumentException("Only a relative path is supported, the given path is absolute: " + potentialChildRelativePath); } Path parentAbsolutePath = Util.fileToPath(parentFile.getAbsoluteFile()); Path parentRealPath; try { parentRealPath = parentAbsolutePath.toRealPath(); } catch(NoSuchFileException e) { throw new IllegalArgumentException("The parent does not exist"); } String remainingPath = potentialChildRelativePath; Path currentFilePath = parentFile.toPath(); while (!remainingPath.isEmpty()) { Path directChild = this.getDirectChild(currentFilePath, remainingPath); Path childUsingFullPath = currentFilePath.resolve(remainingPath); String childUsingFullPathAbs = childUsingFullPath.toAbsolutePath().toString(); String directChildAbs = directChild.toAbsolutePath().toString(); if (childUsingFullPathAbs.length() == directChildAbs.length()) { remainingPath = ""; } else { remainingPath = childUsingFullPathAbs.substring(directChildAbs.length() + 1); } File childFileSymbolic = Util.resolveSymlinkToFile(directChild.toFile()); if (childFileSymbolic == null) { currentFilePath = directChild; } else { currentFilePath = childFileSymbolic.toPath(); } Path currentFileAbsolutePath = currentFilePath.toAbsolutePath(); try{ Path child = currentFileAbsolutePath.toRealPath(); if (!child.startsWith(parentRealPath)) { return false; } } catch (NoSuchFileException e) { Path child = currentFileAbsolutePath.normalize(); Path parent = parentAbsolutePath.normalize(); return child.startsWith(parent); } } return true; }