Skip to content

Commit 6bde23a

Browse files
Exercise tag decoding through built module
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 033b9ff commit 6bde23a

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

tests/ConvertFrom-Yaml.Tests.ps1

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,18 @@ date: !!timestamp 2001-12-14
379379
}
380380

381381
It 'decodes percent escapes in expanded tags using UTF-8' {
382-
$yaml = @'
383-
%TAG !e! tag:example.com,2000:app/
384-
---
385-
first: !e!tag%21 value
386-
second: !e!currency%E2%82%AC amount
387-
'@
388-
$representation = Read-YamlStreamCore -Yaml $yaml -Depth 32 -MaxNodes 64 -MaxAliases 16 `
389-
-MaxScalarLength 4096 -MaxTagLength 1024 -MaxTotalTagLength 4096 `
390-
-MaxNumericLength 64
391-
392-
$representation.Value.Count | Should -Be 1
393-
$entries = $representation.Value[0].Entries
394-
$entries.Count | Should -Be 2
395-
$entries[0].Value.Tag | Should -Be 'tag:example.com,2000:app/tag!'
396-
$entries[1].Value.Tag | Should -Be ('tag:example.com,2000:app/currency' + [char] 0x20AC)
382+
$escaped = Get-TestYamlRepresentationRoot -Yaml (
383+
"%TAG !e! tag:example.com,2000:app/`n--- !e!tag%21 value"
384+
)
385+
$multibyte = Get-TestYamlRepresentationRoot -Yaml (
386+
"%TAG !e! tag:example.com,2000:app/`n--- !e!currency%E2%82%AC amount"
387+
)
388+
389+
$escaped.Tag | Should -Be 'tag:example.com,2000:app/tag!'
390+
$escaped.HasUnknownTag | Should -BeTrue
391+
$multibyte.Tag |
392+
Should -Be ('tag:example.com,2000:app/currency' + [char] 0x20AC)
393+
$multibyte.HasUnknownTag | Should -BeTrue
397394
}
398395

399396
It 'rejects malformed or non-UTF8 tag percent escapes' {

0 commit comments

Comments
 (0)