summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-21 09:18:58 -0700
committerIra Rice <irarice@gmail.com>2009-01-21 09:18:58 -0700
commitda2b9950c5785381e5e7ed541bc33dbecdb51f9c (patch)
treefaafa5fc320c2b5a02c406c12636b4c712ffa113
parent5dff1647df4a05d956b1e1978ec8918c420b9107 (diff)
downloadmana-da2b9950c5785381e5e7ed541bc33dbecdb51f9c.tar.gz
mana-da2b9950c5785381e5e7ed541bc33dbecdb51f9c.tar.bz2
mana-da2b9950c5785381e5e7ed541bc33dbecdb51f9c.tar.xz
mana-da2b9950c5785381e5e7ed541bc33dbecdb51f9c.zip
Fixed multiple embeddings of square brackets so that it doesn't crash
the client. This commit makes it so that all brackets except for the innermost brackets are ignored. Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/being.cpp7
-rw-r--r--src/gui/chat.cpp7
2 files changed, 14 insertions, 0 deletions
diff --git a/src/being.cpp b/src/being.cpp
index c5a98a2d..8ed66c7a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -187,6 +187,13 @@ void Being::setSpeech(const std::string &text, Uint32 time)
while (start != std::string::npos && end != std::string::npos)
{
+ // Catch multiple embeds and ignore them so it doesn't crash the client.
+ while ((mSpeech.find('[', start + 1) != std::string::npos) &&
+ (mSpeech.find('[', start + 1) < end))
+ {
+ start = mSpeech.find('[', start + 1);
+ }
+
std::string::size_type position = mSpeech.find('|');
mSpeech.erase(end, 1);
mSpeech.erase(start, (position - start) + 1);
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index ef625753..a0f12b2c 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -363,6 +363,13 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
std::string::size_type end = msg.find(']', start);
if (end != std::string::npos)
{
+ // Catch multiple embeds and ignore them so it doesn't crash the client.
+ while ((msg.find('[', start + 1) != std::string::npos) &&
+ (msg.find('[', start + 1) < end))
+ {
+ start = msg.find('[', start + 1);
+ }
+
std::string temp = msg.substr(start+1, end - start - 1);
while (temp[0] == ' ')