Quantcast

Will detect malformed data received from AddonMessage and show a message to the user.

F16Gaming [04-30-12 - 22:10]
Will detect malformed data received from AddonMessage and show a message to the user.
Filename
AddonComm.lua
locales/enUS.lua
locales/svSE.lua
diff --git a/AddonComm.lua b/AddonComm.lua
index 5c4f405..e22dff2 100644
--- a/AddonComm.lua
+++ b/AddonComm.lua
@@ -126,6 +126,8 @@ function AC:Receive(msgType, msg, channel, sender)
 					if realm and realm ~= "" then
 						v = ("%s-%s"):format(name, realm)
 					end
+				elseif v:match("^%w+-$") then
+					log:Error(L("AC_ERR_MALFORMED_DATA"):format(sender))
 				end
 				table.insert(self.GroupMembers, v)
 			end
@@ -140,6 +142,8 @@ function AC:Receive(msgType, msg, channel, sender)
 			if realm and realm ~= "" then
 				msg = ("%s-%s"):format(name, realm)
 			end
+		elseif msg:match("^%w+-$") then
+			log:Error(L("AC_ERR_MALFORMED_DATA"):format(sender))
 		end
 		if not CET:HasValue(self.GroupMembers, msg) then
 			table.insert(self.GroupMembers, msg)
@@ -195,6 +199,9 @@ function AC:Send(msgType, msg, channel, target)
 			if realm and realm ~= "" then
 				target = ("%s-%s"):format(name, realm)
 			end
+		elseif target:match("^%w+-$") then
+			log:Error(L("AC_ERR_MALFORMED_DATA_SEND"):format(target))
+			return
 		end
 	end
 	SendAddonMessage(msgType, msg, channel, target)
diff --git a/locales/enUS.lua b/locales/enUS.lua
index 6719706..7c414f2 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -52,6 +52,8 @@ local L = {

 	AC_ERR_PREFIX = "[FATAL] Failed to register AddOn prefix %q. Maximum number of prefixes reached on client.",
 	AC_ERR_MSGTYPE = "Invalid message type specified: %s",
+	AC_ERR_MALFORMED_DATA = "Malformed data received from %s. Their AddOn is probably outdated.",
+	AC_ERR_MALFORMED_DATA_SEND = "[AddonComm] Malformed data detected (\"%s\"). Aborting Send...",

 	AC_GROUP_NORESP = "No response from group, running updater...",
 	AC_GROUP_R_UPDATE = "Updated group members, controller: %s",
diff --git a/locales/svSE.lua b/locales/svSE.lua
index 273997a..369ccd2 100644
--- a/locales/svSE.lua
+++ b/locales/svSE.lua
@@ -52,6 +52,8 @@ local L = {

 	AC_ERR_PREFIX = "[KRITISK] Misslyckades med att registrera AddOn prefix %q. Maximalt antal prefix har nåtts på klienten.",
 	AC_ERR_MSGTYPE = "Ogiltig meddelandetyp: %s",
+	AC_ERR_MALFORMED_DATA = "Ogiltig data från %s. Deras AddOn är antagligen inaktuell.",
+	AC_ERR_MALFORMED_DATA_SEND = "[AddonComm] Malformed data detected (\"%s\"). Aborting Send...",

 	AC_GROUP_NORESP = "Inget svar från grupp, uppdaterar...",
 	AC_GROUP_R_UPDATE = "Gruppmedlemmar uppdaterade, kontrollerare: %s",