/** * Returns true if the path is valid. A <code>null</code> value is considered invalid. * @param path Path value to validate. * @return true if path is valid. */ protected boolean isValidPath(String path) { if (path == null) { return false; } if (!PATH_PATTERN.matcher(path).matches()) { return false; } int slash2Count = countToken("//", path); if (options.isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) { return false; } int slashCount = countToken("/", path); int dot2Count = countToken("..", path); if (dot2Count > 0 && (slashCount - slash2Count - 1) <= dot2Count){ return false; } return true; }
/** * Returns true if the path is valid. A <code>null</code> value is considered invalid. * @param path Path value to validate. * @return true if path is valid. */ protected boolean isValidPath(String path) { if (path == null) { return false; } if (PATH_PATTERN.exec(path) == null) { return false; } int slash2Count = countToken("//", path); if (options.isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) { return false; } int slashCount = countToken("/", path); int dot2Count = countToken("..", path); if (dot2Count > 0 && (slashCount - slash2Count - 1) <= dot2Count){ return false; } return true; }
/** * Returns true if the path is valid. A <code>null</code> value is considered invalid. * @param path Path value to validate. * @return true if path is valid. */ protected boolean isValidPath(String path) { if (path == null) { return false; } Perl5Util pathMatcher = new Perl5Util(); if (!pathMatcher.match(PATH_PATTERN, path)) { return false; } int slash2Count = countToken("//", path); if (this.options.isOff(ALLOW_2_SLASHES) && (slash2Count > 0)) { return false; } int slashCount = countToken("/", path); int dot2Count = countToken("..", path); if (dot2Count > 0) { if ((slashCount - slash2Count - 1) <= dot2Count) { return false; } } return true; }