File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,11 +67,19 @@ function Resolve-YamlRemovalTarget {
6767
6868 $resolvedKey = (Resolve-YamlScalar - Node $keyNode ).Value
6969 $effectiveTag = Get-YamlEffectiveTag - Node $keyNode - Value $resolvedKey
70- if ($effectiveTag -cne ' tag:yaml.org,2002:str' ) {
70+ if (-not [string ]::Equals(
71+ $effectiveTag ,
72+ ' tag:yaml.org,2002:str' ,
73+ [System.StringComparison ]::Ordinal
74+ )) {
7175 $hasUnaddressableKey = $true
7276 continue
7377 }
74- if ([string ] $keyNode.Value -ceq $token ) {
78+ if ([string ]::Equals(
79+ [string ] $keyNode.Value ,
80+ $token ,
81+ [System.StringComparison ]::Ordinal
82+ )) {
7583 $matchingIndexes.Add ($entryIndex )
7684 }
7785 }
Original file line number Diff line number Diff line change @@ -223,6 +223,27 @@ keep: true
223223 $actual | Should - BeExactly (" name: lower`n keep: true" | Format-Yaml )
224224 }
225225
226+ It ' matches mapping key code points ordinally' {
227+ $composed = [string ] [char ] 0x00E9
228+ $decomposed = ' e' + [char ] 0x0301
229+ $yaml = ' "' + $decomposed + ' ": value' + " `n keep: true"
230+
231+ Remove-YamlEntry $yaml (' /' + $composed ) - IgnoreMissing |
232+ Should - BeExactly ($yaml | Format-Yaml )
233+
234+ $result = Remove-YamlEntry $yaml (' /' + $decomposed ) |
235+ ConvertFrom-Yaml - AsHashtable
236+ $result.Contains ($decomposed ) | Should - BeFalse
237+ $result [' keep' ] | Should - BeTrue
238+ }
239+
240+ It ' does not treat a linguistically equal unknown tag as a string tag' {
241+ $yaml = " !<tag:yaml.org,2002:st%C2%ADr> key: tagged`n keep: true"
242+
243+ Remove-YamlEntry $yaml ' /key' - IgnoreMissing |
244+ Should - BeExactly ($yaml | Format-Yaml )
245+ }
246+
226247 It ' treats explicit string keys as strings and plain numeric keys as numbers' {
227248 $yaml = @'
2282491: numeric
You can’t perform that action at this time.
0 commit comments