mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 06:59:44 +07:00
[platform] refining sub-path detection in the Defender configuration script (IJPL-164957)
(cherry picked from commit c11857dc34299b734a93acfbf035c2dcd5b36944) IJ-CR-149682 GitOrigin-RevId: e0263de6336c8078cd897d9c5b5365e618953540
This commit is contained in:
committed by
intellij-monorepo-bot
parent
33ae337a93
commit
c4c67df3c3
@@ -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