diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-03-19 02:30:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-03-19 02:30:27 +0300 |
commit | d8505394ee7e109c3fd1d35450ed106a5ceefcfb (patch) | |
tree | 12430dff4c572cf9bbbdc73b1015be97d0ad60d9 /src/gui | |
parent | cf7db888f4d6f65624d803efe2c14523b77effa6 (diff) | |
download | manaplus-d8505394ee7e109c3fd1d35450ed106a5ceefcfb.tar.gz manaplus-d8505394ee7e109c3fd1d35450ed106a5ceefcfb.tar.bz2 manaplus-d8505394ee7e109c3fd1d35450ed106a5ceefcfb.tar.xz manaplus-d8505394ee7e109c3fd1d35450ed106a5ceefcfb.zip |
Protect autocomplete from evil nicks if nick start from chat line start.
Example nick: @pvp on
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chatwindow.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index eb8669223..d651df87b 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1167,6 +1167,7 @@ void ChatWindow::autoComplete() int caretPos = mChatInput->getCaretPosition(); int startName = 0; const std::string inputText = mChatInput->getText(); + bool needSecure(false); std::string name = inputText.substr(0, caretPos); std::string newName(""); @@ -1189,28 +1190,37 @@ void ChatWindow::autoComplete() if (cTab) cTab->getAutoCompleteList(nameList); newName = autoComplete(nameList, name); + if (!newName.empty()) + needSecure = true; - if (newName == "" && actorSpriteManager) + if (newName.empty() && actorSpriteManager) { actorSpriteManager->getPlayerNames(nameList, true); newName = autoComplete(nameList, name); + if (!newName.empty()) + needSecure = true; } - if (newName == "") + if (newName.empty()) newName = autoCompleteHistory(name); - if (newName == "" && spellManager) + if (newName.empty() && spellManager) newName = spellManager->autoComplete(name); - if (newName == "") + if (newName.empty()) newName = autoComplete(name, &mCommands); - if (newName == "" && actorSpriteManager) + if (newName.empty() && actorSpriteManager) { actorSpriteManager->getMobNames(nameList); newName = autoComplete(nameList, name); } - if (newName == "") + if (newName.empty()) newName = autoComplete(name, &mCustomWords); - if (newName != "") + if (!newName.empty()) { + if (!startName && needSecure && (newName[0] == '/' + || newName[0] == '@' || newName[0] == '#')) + { + newName = "_" + newName; + } mChatInput->setText(inputText.substr(0, startName) + newName + inputText.substr(caretPos, inputText.length() - caretPos)); |