mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform] refining sub-path detection in the Defender configuration script (IJPL-164957)
GitOrigin-RevId: c11857dc34299b734a93acfbf035c2dcd5b36944
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4dcae790f2
commit
daab24a7ff
@@ -34,10 +34,18 @@ try {
|
||||
return $result
|
||||
}
|
||||
|
||||
# returns `$true` when the given path is a sub-path of the given parent
|
||||
function Test-StartsWith ([string] $path, [string] $parent) {
|
||||
$pathNorm = $path.Trim('\') + '\'
|
||||
$parentNorm = $parent.Trim('\') + '\'
|
||||
return $pathNorm.Equals($parentNorm, [StringComparison]::OrdinalIgnoreCase) -or `
|
||||
$pathNorm.StartsWith($parentNorm, [StringComparison]::OrdinalIgnoreCase)
|
||||
}
|
||||
|
||||
# returns `$true` when a path is already covered by the exclusion list
|
||||
function Test-Excluded ([string] $path, [string[]] $exclusions) {
|
||||
foreach ($exclusion in $exclusions) {
|
||||
if (((Get-Item -Path $exclusion) -is [System.IO.DirectoryInfo]) -and ([cultureinfo]::InvariantCulture.CompareInfo.IsPrefix($path, $exclusion, @("IgnoreCase"))) -and ($exclusion.TrimEnd('\').split('\').Count -gt $path.TrimEnd('\').Split('\').Count)) {
|
||||
if (Test-StartsWith $path $exclusion) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user