Fixing strange bugs in getCertNames
Avoid reading input to stringbuf and then parsing. boost::tokenizer can
work directly on streams (with some hacks).
diff --git a/src/browsecontactdialog.cpp b/src/browsecontactdialog.cpp
index 78a6ab4..0ec1e37 100644
--- a/src/browsecontactdialog.cpp
+++ b/src/browsecontactdialog.cpp
@@ -112,29 +112,20 @@
while (std::getline(request_stream, header) && header != "\r")
headers.push_back(header);
- std::stringbuf buffer;
- std::ostream os (&buffer);
+ std::istreambuf_iterator<char> stream_iter (request_stream);
+ std::istreambuf_iterator<char> end_of_stream;
- os << request_stream.rdbuf();
-
- using boost::tokenizer;
- using boost::escaped_list_separator;
+ typedef boost::tokenizer< boost::escaped_list_separator<char>, std::istreambuf_iterator<char> > tokenizer_t;
+ tokenizer_t certItems (stream_iter, end_of_stream,boost::escaped_list_separator<char>('\\', '\n', '"'));
- tokenizer<escaped_list_separator<char> > certItems(buffer.str(), escaped_list_separator<char> ('\\', '\n', '"'));
- tokenizer<escaped_list_separator<char> >::iterator it = certItems.begin();
- try{
- while (it != certItems.end())
- {
- if (!it->empty())
- {
- names.push_back(*it);
- }
- it++;
- }
- }catch (exception &e){
- QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #5"));
- }
-
+ for (tokenizer_t::iterator it = certItems.begin();
+ it != certItems.end (); it++)
+ {
+ if (!it->empty())
+ {
+ names.push_back(*it);
+ }
+ }
}catch(std::exception &e){
QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #N"));
}
@@ -183,13 +174,16 @@
for(; it != certNameList.end(); it++)
{
- try{
- Name name(*it);
- m_certificateNameList.push_back(name);
+ try {
+ m_certificateNameList.push_back(Name (*it));
}
catch(error::Name)
{
- ; // do nothing
+ _LOG_ERROR ("Error parsing: [" << *it << "]");
+ }
+ catch(error::name::Component)
+ {
+ _LOG_ERROR ("Error parsing: [" << *it << "]");
}
}
}