mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-12 13:40:19 +07:00
[json] IJPL-181564 JSON schema path matcher is not robust to errors in schema catalog
(cherry picked from commit 067ea6e8c77f1df5cc2b91c5984ae2ef9a9cdcee) IJ-CR-158093 GitOrigin-RevId: a188846ccc2caf9d9b9d54f58f34e4b9d2910d99
This commit is contained in:
committed by
intellij-monorepo-bot
parent
826155474b
commit
cf7ea51c9b
@@ -7,7 +7,9 @@ import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.lightEdit.LightEdit;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -446,7 +448,16 @@ public class JsonSchemaServiceImpl implements JsonSchemaService, ModificationTra
|
||||
}
|
||||
|
||||
private @Nullable VirtualFile resolveSchemaFromOtherSources(@NotNull VirtualFile file) {
|
||||
return myCatalogManager.getSchemaFileForFile(file);
|
||||
try {
|
||||
return myCatalogManager.getSchemaFileForFile(file);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeExceptionWithAttachments("Unable to resolve JSON schema from file " + file.getName(), e,
|
||||
new Attachment("Schema URL", file.getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -31,8 +32,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public final class JsonSchemaCatalogManager {
|
||||
private static final Logger LOG = Logger.getInstance(JsonSchemaCatalogManager.class);
|
||||
|
||||
static final String DEFAULT_CATALOG = "http://schemastore.org/api/json/catalog.json";
|
||||
static final String DEFAULT_CATALOG_HTTPS = "https://schemastore.org/api/json/catalog.json";
|
||||
private static final Set<String> SCHEMA_URL_PREFIXES_WITH_TOO_MANY_VARIANTS = Set.of(
|
||||
@@ -181,13 +185,21 @@ public final class JsonSchemaCatalogManager {
|
||||
path = Paths.get(filePath);
|
||||
}
|
||||
catch (InvalidPathException e) {
|
||||
LOG.debug("Unable to process invalid path '" + filePath + "'", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (FileMatcher matcher : matchers) {
|
||||
if (matcher.matches(path)) {
|
||||
return matcher.myEntry.getUrl();
|
||||
try {
|
||||
if (matcher.matches(path)) {
|
||||
return matcher.myEntry.getUrl();
|
||||
}
|
||||
}
|
||||
catch (PatternSyntaxException pse) {
|
||||
LOG.warn("Unable to process matches for path '" + path + "' with matcher URL '" + matcher.myEntry.getUrl() + "'", pse);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user