summaryrefslogtreecommitdiff
path: root/src/being.cpp
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 /src/being.cpp
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>
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp7
1 files changed, 7 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);