Skip to content

Commit

Permalink
Escape formspec values. Fixes #1723
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Oct 10, 2024
1 parent 0b8d958 commit 7a2af6a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions mods/lord/Core/builtin/src/FormSpec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ end
---
--- @return string
function FormSpec.pwdfield(X,Y,W,H,name,label)
return 'pwdfield['..X..','..Y..';' ..W..','..H..';'..name..optional(label)..']'
return 'pwdfield['..X..','..Y..';' ..W..','..H..';'..name..optional(e(label))..']'
end

---
Expand All @@ -433,7 +433,7 @@ end
---
--- @return string
function FormSpec.field(X,Y,W,H,name,label,default)
return 'field['..X..','..Y..';' ..W..','..H..';'..name..optional(e(label))..optional(default)..']'
return 'field['..X..','..Y..';' ..W..','..H..';'..name..optional(e(label))..optional(e(default))..']'
end

---
Expand All @@ -447,7 +447,7 @@ end
---
--- @return string
function FormSpec.field2(name,label,default)
return 'field['..name..optional(e(label))..optional(default)..']'
return 'field['..name..optional(e(label))..optional(e(default))..']'
end

---
Expand Down Expand Up @@ -482,7 +482,7 @@ end
---
--- @return string
function FormSpec.textarea(X,Y,W,H,name,label,default)
return 'textarea['..X..','..Y..';' ..W..','..H..';'..name..optional(e(label))..optional(default)..']'
return 'textarea['..X..','..Y..';' ..W..','..H..';'..name..optional(e(label))..optional(e(default))..']'
end

---
Expand Down Expand Up @@ -510,7 +510,7 @@ end
---
--- @return string
function FormSpec.hypertext(X,Y,W,H,name,text)
return 'hypertext['..X..','..Y..';' ..W..','..H..';'..name..';'..text..']'
return 'hypertext['..X..','..Y..';' ..W..','..H..';'..name..';'..e(text)..']'
end

--- * Textual label drawn vertically
Expand Down Expand Up @@ -583,7 +583,7 @@ end
---
--- @return string
function FormSpec.button_exit(X,Y,W,H,name,label)
return 'button_exit['..X..','..Y..';' ..W..','..H..';'..name..';'..label..']'
return 'button_exit['..X..','..Y..';' ..W..','..H..';'..name..';'..e(label)..']'
end

---
Expand All @@ -592,7 +592,7 @@ end
---
--- @return string
function FormSpec.button_url_exit(X,Y,W,H,name,label,url)
return 'button_url_exit['..X..','..Y..';' ..W..','..H..';'..name..';'..label..';'..url..']'
return 'button_url_exit['..X..','..Y..';' ..W..','..H..';'..name..';'..e(label)..';'..e(url)..']'
end

---
Expand All @@ -601,7 +601,7 @@ end
---
--- @return string
function FormSpec.image_button_exit(X,Y,W,H,texture_name,name,label)
return 'image_button_exit['..X..','..Y..';' ..W..','..H..';'..texture_name..';'..name..optional(label)..']'
return 'image_button_exit['..X..','..Y..';' ..W..','..H..';'..texture_name..';'..name..optional(e(label))..']'
end

---
Expand Down Expand Up @@ -771,9 +771,10 @@ end
--- * **Note**: If the new coordinate system is enabled, checkboxes are
--- positioned from the center of the checkbox, not the top.
---
--- @param selected boolean
--- @return string
function FormSpec.checkbox(X,Y,name,label,selected)
return 'checkbox['..X..','..Y..';' .. name..optional(e(label))..optional(selected)..']'
return 'checkbox['..X..','..Y..';' .. name..optional(e(label))..optional(bool_str(selected))..']'
end

---
Expand Down

0 comments on commit 7a2af6a

Please sign in to comment.