From 5d05ab6d98f3376a70e3a939bc76521dee205a9d Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 12 Oct 2017 21:13:36 +0300 Subject: [PATCH] platform: normalize descriptor paths to find paths starting with './' That will sync behavior of IDE started from sources (where descriptors are loaded from files) and built IDE (where descriptors are loaded from jar files). Also, that will allow to specify paths uniformly in `xi:include` and `depends`, e.g. com.intellij.modules.coverage --- .../ide/plugins/PluginManagerCore.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java index 381bb253ff4e..7dcf877da128 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java @@ -57,10 +57,7 @@ import org.jetbrains.annotations.TestOnly; import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; +import java.net.*; import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -680,7 +677,7 @@ public class PluginManagerCore { @NotNull JDOMXIncluder.PathResolver pathResolver, @NotNull LoadingContext context) { try { - URL jarURL = URLUtil.getJarEntryURL(file, META_INF + '/' + fileName); + URL jarURL = URLUtil.getJarEntryURL(file, getNormalizedPathInJar(fileName)); ZipFile zipFile = context.myOpenedFiles.get(file); if (zipFile == null) { @@ -707,6 +704,17 @@ public class PluginManagerCore { return null; } + @NotNull + private static String getNormalizedPathInJar(@NotNull String pathInJar) { + String absolutePathInJar = META_INF + '/' + pathInJar; + try { + return new URI(absolutePathInJar).normalize().getPath(); + } + catch (URISyntaxException ignored) { + } + return absolutePathInJar; + } + @Nullable public static IdeaPluginDescriptorImpl loadDescriptor(@NotNull final File file, @NotNull String fileName) { try (LoadingContext context = new LoadingContext()) {