File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 $escaped = $Key `
3333 -replace ' \\' , ' \\' `
3434 -replace ' "' , ' \"' `
35+ -replace " `0 " , ' \0' `
36+ -replace " `a " , ' \a' `
3537 -replace " `n " , ' \n' `
3638 -replace " `r " , ' \r' `
3739 -replace " `t " , ' \t' `
40+ -replace " `v " , ' \v' `
3841 -replace " `b " , ' \b' `
3942 -replace " `f " , ' \f'
4043 return " [`" $escaped `" ]"
Original file line number Diff line number Diff line change 122122 if ($script :luaPos -lt $script :luaString.Length -and
123123 $script :luaString [$script :luaPos ] -eq ' }' ) {
124124 $script :luaPos ++ # skip }
125+ } else {
126+ $script :luaCurrentDepth --
127+ throw " Unterminated Lua table constructor. Expected '}' before end of input."
125128 }
126129
127130 $script :luaCurrentDepth --
Original file line number Diff line number Diff line change 8585 process {
8686 $result = ConvertFrom-LuaTable - InputString $InputObject - AsPSCustomObject:(-not $AsHashtable ) - MaxDepth $Depth
8787 if ($NoEnumerate -and $result -is [System.Array ]) {
88- Write-Output - NoEnumerate $result
88+ Write-Output - InputObject $result - NoEnumerate
8989 } else {
9090 $result
9191 }
Original file line number Diff line number Diff line change @@ -476,6 +476,10 @@ B = { val = 2 }
476476 It ' Throws on unterminated multi-line string' {
477477 { ConvertFrom-Lua - InputObject ' [[hello' } | Should - Throw ' *Unterminated*'
478478 }
479+
480+ It ' Throws on unterminated table (missing closing brace)' {
481+ { ConvertFrom-Lua - InputObject ' { a = 1' } | Should - Throw ' *Unterminated*'
482+ }
479483 }
480484
481485 Context ' Pipeline input' {
@@ -879,6 +883,12 @@ Describe 'ConvertTo-Lua' {
879883 $result = ConvertTo-Lua - InputObject @ { ' while' = ' loop' } - Compress
880884 $result | Should - Be ' {["while"]="loop"}'
881885 }
886+
887+ It ' Escapes control characters in bracket-quoted keys' {
888+ $key = " line1`n line2"
889+ $result = ConvertTo-Lua - InputObject @ { $key = ' value' } - Compress
890+ $result | Should - Be ' {["line1\nline2"]="value"}'
891+ }
882892 }
883893
884894 Context ' PSCustomObject' {
You can’t perform that action at this time.
0 commit comments