diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da62d289..ba65bffbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - limit warn / error messages to 500 characters - use dumb aware to limit scans during startup - add no_proxy environment variable, if proxy exceptions are defined +- be able to process findings in folder and file names that contain URL encoding ## [2.9.1] ### Fixed diff --git a/src/main/kotlin/io/snyk/plugin/Utils.kt b/src/main/kotlin/io/snyk/plugin/Utils.kt index bbb5b0976..7e2c5e912 100644 --- a/src/main/kotlin/io/snyk/plugin/Utils.kt +++ b/src/main/kotlin/io/snyk/plugin/Utils.kt @@ -62,6 +62,7 @@ import java.io.File import java.io.FileNotFoundException import java.net.URI import java.nio.file.Path +import java.nio.file.Paths import java.util.Objects.nonNull import java.util.SortedSet import java.util.concurrent.TimeUnit @@ -390,7 +391,7 @@ fun String.toVirtualFile(): VirtualFile { return if (!this.startsWith("file://")) { StandardFileSystems.local().refreshAndFindFileByPath(this) ?: throw FileNotFoundException(this) } else { - VirtualFileManager.getInstance().refreshAndFindFileByUrl(this.toVirtualFileURL()) + VirtualFileManager.getInstance().refreshAndFindFileByNioPath(convertUriToPath(this.toVirtualFileURL())) ?: throw FileNotFoundException(this) } } @@ -411,6 +412,12 @@ fun String.toVirtualFileURL(): String { return this } +fun convertUriToPath(encodedUri: String): Path { + val uri = URI(encodedUri) + val path = Paths.get(uri) + return path +} + fun String.isWindowsURI() = SystemUtils.IS_OS_WINDOWS && this.startsWith("file://") fun VirtualFile.urlContainsDriveLetter() = diff --git a/src/main/kotlin/snyk/common/lsp/LanguageServerBulkFileListener.kt b/src/main/kotlin/snyk/common/lsp/LanguageServerBulkFileListener.kt index f33736a7d..81cffbcc5 100644 --- a/src/main/kotlin/snyk/common/lsp/LanguageServerBulkFileListener.kt +++ b/src/main/kotlin/snyk/common/lsp/LanguageServerBulkFileListener.kt @@ -123,7 +123,7 @@ class LanguageServerBulkFileListener : SnykBulkFileListener() { VirtualFileManager.getInstance().asyncRefresh() invokeLater { - if (SnykPluginDisposable.getInstance(project).isDisposed() || project.isDisposed) return@invokeLater + if (project.isDisposed || SnykPluginDisposable.getInstance(project).isDisposed()) return@invokeLater DaemonCodeAnalyzer.getInstance(project).restart() } }