Sanitize [ and ] so SavedVariables doesn't bug out.
Scott Yeskie [05-23-14 - 02:05]
Sanitize [ and ] so SavedVariables doesn't bug out.
diff --git a/GuildCharNames.lua b/GuildCharNames.lua
index 37444a3..28f9acd 100644
--- a/GuildCharNames.lua
+++ b/GuildCharNames.lua
@@ -159,6 +159,8 @@ GuildCharInfo.generateLink = function(acctName)
if color == nil or #color ~= 6 then color = "EEEEEE" end
if text == nil then text = "[*]" end
+ text = GuildCharInfo.unsanitizeSavedText(text)
+
local data = acctName
data = data .. "," .. GuildCharInfo.lut[acctName].guild
data = data .. "," .. GuildCharInfo.lut[acctName].index
@@ -310,6 +312,20 @@ GuildCharInfo.hex2dec = function(dd)
return tonumber(dd)
end
+GuildCharInfo.sanitizeSavedText = function(txt)
+ txt = txt:gsub("&","&a;")
+ txt = txt:gsub("%[","&o;")
+ txt = txt:gsub("]","&c;")
+ return txt
+end
+
+GuildCharInfo.unsanitizeSavedText = function(txt)
+ txt = txt:gsub("&o;", "[")
+ txt = txt:gsub("&c;", "]")
+ txt = txt:gsub("&a;", "&")
+ return txt
+end
+
--[[
Init function to create UI configuration menu and managed config variables
@post - UI menu created
@@ -321,7 +337,7 @@ GuildCharInfo.initUI = function()
cfgDefault.showMain = true
cfgDefault.showAcct = false
cfgDefault.showLink = true
- cfgDefault.linkText = "[*]"
+ cfgDefault.linkText = "&o;*&c;]"
cfgDefault.linkColor = "EEEEEE"
GuildCharInfo.cfg = ZO_SavedVars:NewAccountWide('GuildCharacterInfo', 0.9, "config", cfgDefault)
--
@@ -361,8 +377,8 @@ GuildCharInfo.initUI = function()
LAM:AddEditBox(GuildCharInfo.panelID, pre.."h2c3", "Link text",
"Text shown after character name which on click shows the info box",
false, -- Not multiline
- function() return GuildCharInfo.cfg.linkText end,
- function(val) GuildCharInfo.cfg.linkText = val end,
+ function() return GuildCharInfo.unsanitizeSavedText(GuildCharInfo.cfg.linkText) end,
+ function(val) GuildCharInfo.cfg.linkText = GuildCharInfo.sanitizeSavedText(val) end,
true, "If using pChat, do NOT include a '^' in the link text"
)
end
diff --git a/GuildCharacterInfo.txt b/GuildCharacterInfo.txt
index f7a7ee4..94b3462 100644
--- a/GuildCharacterInfo.txt
+++ b/GuildCharacterInfo.txt
@@ -7,6 +7,7 @@
lib/LibStub.lua
lib/libChat.lua
+lib/LibAddonMenu-1.0.lua
GuildCharNames.lua