diff --git a/linphone-app/src/utils/UriTools.cpp b/linphone-app/src/utils/UriTools.cpp index 2e8c1121f..07a147fe7 100644 --- a/linphone-app/src/utils/UriTools.cpp +++ b/linphone-app/src/utils/UriTools.cpp @@ -26,6 +26,8 @@ #include "UriTools.hpp" +#include + static UriTools gUriTools; UriTools::UriTools(){ @@ -45,22 +47,23 @@ QVector > UriTools::parse(const QString& text, const QRegul QVector > results; int currentIndex = 0; auto match = regex.match(text); - + int lastCapturedIndex = match.lastCapturedIndex(); for (int i = 0; i <= match.lastCapturedIndex(); ++i) { int startIndex = match.capturedStart(i); - if(currentIndex != startIndex){ + if(currentIndex != startIndex){// characters before startIndex doesn't match results.push_back({false, text.mid(currentIndex, startIndex - currentIndex)}); } results.push_back({true, match.captured(i)}); - currentIndex = startIndex; + currentIndex = match.capturedEnd(i); } - if(results.size() == 0) + if(lastCapturedIndex == -1) results.push_back({false, text}); else{ - currentIndex += results.back().second.length(); - if( currentIndex < text.size()) - results.push_back({false, text.mid(currentIndex)}); + if( currentIndex < text.size()) { + QString unparsedText = text.mid(currentIndex); + results.append(parse(unparsedText, regex)); + } } return results; }