Skip to content

Commit e22dffe

Browse files
Address PR review feedback
1 parent 7242d0c commit e22dffe

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

.github/linters/.luacheckrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- Test data files are Lua data/config files (e.g. WoW SavedVariables format)
22
-- that define top-level globals and are not executed as scripts.
3-
files["**/tests/data/Assignments.lua"].ignore = {""}
4-
files["**/tests/data/WoWSavedVariables.lua"].ignore = {""}
3+
files["**/tests/data/Assignments.lua"].ignore = {"111", "112"}
4+
files["**/tests/data/WoWSavedVariables.lua"].ignore = {"111", "112"}

src/functions/private/Format-LuaKey.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@
2929
if ($Key -match '^[a-zA-Z_][a-zA-Z0-9_]*$' -and $Key -notin $reservedWords) {
3030
return $Key
3131
}
32-
$escaped = $Key -replace '\\', '\\\\' -replace '"', '\"'
32+
$escaped = $Key `
33+
-replace '\\', '\\\\' `
34+
-replace '"', '\"' `
35+
-replace "`n", '\n' `
36+
-replace "`r", '\r' `
37+
-replace "`t", '\t' `
38+
-replace "`b", '\b' `
39+
-replace "`f", '\f'
3340
return "[`"$escaped`"]"
3441
}
3542

src/functions/private/Read-LuaString.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@
153153
break
154154
}
155155
}
156-
$null = $result.Append([char][int]$numStr)
156+
$byteValue = [int]$numStr
157+
if ($byteValue -gt 255) {
158+
throw "Invalid decimal escape sequence '\$numStr'. Lua decimal escapes must be in the range 0-255."
159+
}
160+
$null = $result.Append([char]$byteValue)
157161
} else {
158162
# Unknown escape - just pass through
159163
$null = $result.Append($nextChar)

src/functions/private/Skip-LuaWhitespace.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@
3939
$script:luaPos = $eqStart + $eqCount + 1
4040
$closePattern = ']' + ('=' * $eqCount) + ']'
4141
$closeLen = $closePattern.Length
42+
$foundClosingDelimiter = $false
4243
while ($script:luaPos -lt $script:luaString.Length) {
4344
if ($script:luaPos + $closeLen - 1 -lt $script:luaString.Length -and
4445
$script:luaString.Substring($script:luaPos, $closeLen) -eq $closePattern) {
4546
$script:luaPos += $closeLen
47+
$foundClosingDelimiter = $true
4648
break
4749
}
4850
$script:luaPos++
4951
}
52+
if (-not $foundClosingDelimiter) {
53+
throw "Unterminated long-bracket comment."
54+
}
5055
} else {
5156
# Not a long bracket - treat as single-line comment
5257
while ($script:luaPos -lt $script:luaString.Length -and

0 commit comments

Comments
 (0)