Package com.atlassian.confluence.util
Class FilesystemUtils
java.lang.Object
com.atlassian.confluence.util.FilesystemUtils
- Since:
- 8.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Deprecated.since 9.2.4.static boolean
containsEncodedPathTraversal
(String str, Charset charset) Checks if the given string contains any of the forbidden path traversal patterns or in their encoded form.static String
getFileChecksum
(String path) static boolean
isSafePath
(String path) Ensures the path is safe and is not vulnerable to path traversal vulnerabilities.static boolean
isSafePath
(Path path) static boolean
isSafeTitleForFilesystem
(String title) Ensure the title is safe to be written to the file system.
-
Constructor Details
-
FilesystemUtils
public FilesystemUtils()
-
-
Method Details
-
isSafeTitleForFilesystem
Ensure the title is safe to be written to the file system.- Parameters:
title
- The title to check- Returns:
- True if the title is safe for the filesystem, false otherwise
-
containsEncodedPathTraversal
Checks if the given string contains any of the forbidden path traversal patterns or in their encoded form.- Parameters:
str
- The string to check- Returns:
- true if the string contains any of the forbidden path traversal patterns
-
containsEncodedPathTraversal
Deprecated.since 9.2.4. UsecontainsEncodedPathTraversal(String, Charset)
instead. -
isSafePath
Ensures the path is safe and is not vulnerable to path traversal vulnerabilities. On top of filesystem specific checks it also rejects any paths containing risky path elements known to cause path traversal issues in different file systems (e.g. `..`, `/..`, `..\`).- Parameters:
path
- The path to check- Returns:
- True if the path is safe
-
isSafePath
- Parameters:
path
- The path to check- Returns:
- True if the path is safe
- See Also:
-
getFileChecksum
-