summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2016-04-29 07:09:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-29 07:09:28 +0000
commitecd73f48fe219cf238c4c2ec692c42855787bde0 (patch)
tree2bd8b28c1cf9f4cefa5e1eb59799a4bc56ec5e4f /core/java/android
parentcbb128a5d8f8e6c028239603139d17b6b6cbd885 (diff)
parent0693fd85f69db553204168eeb342e6bf0b5fe7b5 (diff)
Merge "Frameworks/base: Use holder in FileUtils" into nyc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/FileUtils.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 7d74a1234c26..fa32848e6362 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -72,8 +72,13 @@ public class FileUtils {
public static final int S_IWOTH = 00002;
public static final int S_IXOTH = 00001;
- /** Regular expression for safe filenames: no spaces or metacharacters */
- private static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+");
+ /** Regular expression for safe filenames: no spaces or metacharacters.
+ *
+ * Use a preload holder so that FileUtils can be compile-time initialized.
+ */
+ private static class NoImagePreloadHolder {
+ public static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+");
+ }
private static final File[] EMPTY = new File[0];
@@ -243,7 +248,7 @@ public class FileUtils {
// Note, we check whether it matches what's known to be safe,
// rather than what's known to be unsafe. Non-ASCII, control
// characters, etc. are all unsafe by default.
- return SAFE_FILENAME_PATTERN.matcher(file.getPath()).matches();
+ return NoImagePreloadHolder.SAFE_FILENAME_PATTERN.matcher(file.getPath()).matches();
}
/**