Skip to content

Commit

Permalink
Escape percentage signs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbartlett21 committed Jan 29, 2025
1 parent ec648bc commit b2ae29f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10315,6 +10315,8 @@ a.types[i], b.types[i]), }
end
end

local keyg = key:gsub('%%', '%%%%')

if t.fields then
assert(t.fields, "record has no fields!?")

Expand All @@ -10330,12 +10332,12 @@ a.types[i], b.types[i]), }

if rec.kind == "variable" then
if t.typename == "interface" then
return nil, "invalid key '" .. key .. "' in '" .. rec.tk .. "' of interface type %s"
return nil, "invalid key '" .. keyg .. "' in '" .. rec.tk .. "' of interface type %s"
else
return nil, "invalid key '" .. key .. "' in record '" .. rec.tk .. "' of type %s"
return nil, "invalid key '" .. keyg .. "' in record '" .. rec.tk .. "' of type %s"
end
else
return nil, "invalid key '" .. key .. "' in type %s"
return nil, "invalid key '" .. keyg .. "' in type %s"
end
elseif t.typename == "emptytable" or is_unknown(t) then
if self.feat_lax then
Expand All @@ -10345,9 +10347,9 @@ a.types[i], b.types[i]), }
end

if rec.kind == "variable" then
return nil, "cannot index key '" .. key .. "' in variable '" .. rec.tk .. "' of type %s"
return nil, "cannot index key '" .. keyg .. "' in variable '" .. rec.tk .. "' of type %s"
else
return nil, "cannot index key '" .. key .. "' in type %s"
return nil, "cannot index key '" .. keyg .. "' in type %s"
end
end

Expand Down Expand Up @@ -10612,7 +10614,7 @@ a.types[i], b.types[i]), }
local field_names = sorted_keys(rb.enumset)
for _, k in ipairs(field_names) do
if not ra.fields[k] then
errm, erra = "enum value '" .. k .. "' is not a field in %s", ra
errm, erra = "enum value '" .. k:gsub('%%', '%%%%') .. "' is not a field in %s", ra
break
end
end
Expand Down
14 changes: 8 additions & 6 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -10315,6 +10315,8 @@ do
end
end

local keyg = key:gsub('%%', '%%%%')

if t is RecordLikeType then
assert(t.fields, "record has no fields!?")

Expand All @@ -10330,12 +10332,12 @@ do

if rec.kind == "variable" then
if t is InterfaceType then
return nil, "invalid key '" .. key .. "' in '" .. rec.tk .. "' of interface type %s"
return nil, "invalid key '" .. keyg .. "' in '" .. rec.tk .. "' of interface type %s"
else
return nil, "invalid key '" .. key .. "' in record '" .. rec.tk .. "' of type %s"
return nil, "invalid key '" .. keyg .. "' in record '" .. rec.tk .. "' of type %s"
end
else
return nil, "invalid key '" .. key .. "' in type %s"
return nil, "invalid key '" .. keyg .. "' in type %s"
end
elseif t is EmptyTableType or is_unknown(t) then
if self.feat_lax then
Expand All @@ -10345,9 +10347,9 @@ do
end

if rec.kind == "variable" then
return nil, "cannot index key '" .. key .. "' in variable '" .. rec.tk .. "' of type %s"
return nil, "cannot index key '" .. keyg .. "' in variable '" .. rec.tk .. "' of type %s"
else
return nil, "cannot index key '" .. key .. "' in type %s"
return nil, "cannot index key '" .. keyg .. "' in type %s"
end
end

Expand Down Expand Up @@ -10612,7 +10614,7 @@ do
local field_names: {string} = sorted_keys(rb.enumset)
for _, k in ipairs(field_names) do
if not ra.fields[k] then
errm, erra = "enum value '" .. k .. "' is not a field in %s", ra
errm, erra = "enum value '" .. k:gsub('%%', '%%%%') .. "' is not a field in %s", ra
break
end
end
Expand Down

0 comments on commit b2ae29f

Please sign in to comment.