trusted-projects: don't allow exceptions to prevent checking if a path is trusted: IDEA-288379

GitOrigin-RevId: 7a030457bab42e38d19ab10c770f915d422537d7
This commit is contained in:
Kirill Likhodedov
2022-03-08 11:41:04 +00:00
committed by intellij-monorepo-bot
parent 85ec50e56a
commit d2bf3cf8ab
@@ -1,7 +1,8 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.impl
import com.intellij.openapi.components.*
import com.intellij.openapi.diagnostic.logger
import com.intellij.util.io.isAncestor
import com.intellij.util.xmlb.annotations.OptionTag
import java.nio.file.Path
@@ -18,7 +19,13 @@ internal class TrustedPathsSettings : SimplePersistentStateComponent<TrustedPath
}
fun isPathTrusted(path: Path): Boolean {
return state.trustedPaths.map { Paths.get(it) }.any { it.isAncestor(path) }
return try {
state.trustedPaths.map { Paths.get(it) }.any { it.isAncestor(path) }
}
catch (e: Exception) {
LOG.warn(e)
false
}
}
fun getTrustedPaths(): List<String> = Collections.unmodifiableList(state.trustedPaths)
@@ -30,4 +37,8 @@ internal class TrustedPathsSettings : SimplePersistentStateComponent<TrustedPath
fun addTrustedPath(path: String) {
state.trustedPaths.add(path)
}
companion object {
val LOG = logger<TrustedPathsSettings>()
}
}