linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #01379
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2167: Be stricter when parsing list-looking %[line:] params
------------------------------------------------------------
revno: 2167
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Mon 2010-06-21 17:15:11 +0200
message:
Be stricter when parsing list-looking %[line:] params
modified:
changelog.txt
win32/WinUtil.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2010-06-18 12:09:55 +0000
+++ changelog.txt 2010-06-21 15:15:11 +0000
@@ -3,6 +3,7 @@
* Reduce donwload reconnect attempts after connection failures (poy)
* Fix crashes related to file lists (poy)
* [L#230973] Add MiniUPnPc for UPnP mappings and make it threaded (poy)
+* Be stricter when parsing list-looking %[line:] params (poy)
-- 0.762 2010-05-16 --
* Stability improvement related to menus (poy)
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2010-05-08 19:13:52 +0000
+++ win32/WinUtil.cpp 2010-06-21 15:15:11 +0000
@@ -22,6 +22,8 @@
#include "resource.h"
+#include <boost/lexical_cast.hpp>
+
#include <dcpp/SettingsManager.h>
#include <dcpp/ShareManager.h>
#include <dcpp/ClientManager.h>
@@ -689,21 +691,24 @@
// let's break between slashes (while ignoring double-slashes) to see if it's a combo
int combo_sel = -1;
- tstring name_ = caption;
- Util::replace(_T("//"), _T("\t"), name_);
- TStringList combo_values = StringTokenizer<tstring>(name_, _T('/')).getTokens();
+ tstring combo_caption = caption;
+ Util::replace(_T("//"), _T("\t"), combo_caption);
+ TStringList combo_values = StringTokenizer<tstring>(combo_caption, _T('/')).getTokens();
if(combo_values.size() > 2) { // must contain at least: caption, default sel, 1 value
TStringIter first = combo_values.begin();
- caption = *first;
+ combo_caption = *first;
combo_values.erase(first);
first = combo_values.begin();
- combo_sel = Util::toUInt(Text::fromT(*first));
+ try { combo_sel = boost::lexical_cast<size_t>(Text::fromT(*first)); }
+ catch(const boost::bad_lexical_cast&) { combo_sel = -1; }
combo_values.erase(first);
if(static_cast<size_t>(combo_sel) >= combo_values.size())
- combo_sel = 0; // default selection value too high
+ combo_sel = -1; // default selection value too high
+ }
+ if(combo_sel >= 0) {
for(TStringIter i = combo_values.begin(), iend = combo_values.end(); i != iend; ++i)
Util::replace(_T("\t"), _T("/"), *i);
@@ -711,13 +716,13 @@
TStringIterC prev = find(combo_values.begin(), combo_values.end(), Text::toT(sm["line:" + name]));
if(prev != combo_values.end())
combo_sel = prev - combo_values.begin();
- }
-
- if(combo_sel >= 0) {
- dlg.addComboBox(caption, combo_values, combo_sel);
+
+ dlg.addComboBox(combo_caption, combo_values, combo_sel);
+
} else {
dlg.addTextBox(caption, Text::toT(sm["line:" + name]));
}
+
names.push_back(name);
}
i = j + 1;