From e1719a15f6c2d13b69045b7be54dc594fdbea153 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 5 Sep 2014 09:40:05 +0200 Subject: [PATCH] =?UTF-8?q?move=20check=20before=20expand=20=E2=80=94=20ex?= =?UTF-8?q?panded=20file=20path=20could=20contain=20"$...$"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/stores/StateStorageManagerImpl.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java index 69a8a38a7901..f8b05cc73b70 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java @@ -335,22 +335,18 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di @Override @NotNull public synchronized String expandMacros(@NotNull String file) { + Matcher matcher = MACRO_PATTERN.matcher(file); + while (matcher.find()) { + String m = matcher.group(1); + if (!myMacros.containsKey(m)) { + throw new IllegalArgumentException("Unknown macro: " + m + " in storage file spec: " + file); + } + } + String expanded = file; for (String macro : myMacros.keySet()) { expanded = StringUtil.replace(expanded, macro, myMacros.get(macro)); } - - // PHP tests use $ as part of name and resulting project name will contain macros-like string - if (!ApplicationManager.getApplication().isUnitTestMode()) { - final Matcher matcher = MACRO_PATTERN.matcher(expanded); - while (matcher.find()) { - String m = matcher.group(1); - if (m != null && !myMacros.containsKey(m)) { - throw new IllegalArgumentException("Unknown macro: " + m + " in storage file spec: " + file); - } - } - } - return expanded; }