From 827eb0b517b48a8439fc04a235872fe0e1157f22 Mon Sep 17 00:00:00 2001 From: Anders Arnholm Date: Fri, 6 Feb 2009 13:45:56 +0100 Subject: [PATCH] Don't crash oc out_of_bounds.... --- linden/indra/llcommon/llversionviewer.h | 2 +- linden/indra/llui/lltexteditor.cpp | 80 +++++++++++++++++------------- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/linden/indra/llcommon/llversionviewer.h b/linden/indra/llcommon/llversionviewer.h index 4b99b71..78bf8fa 100644 --- a/linden/indra/llcommon/llversionviewer.h +++ b/linden/indra/llcommon/llversionviewer.h @@ -45,6 +45,6 @@ const char * const IMP_VIEWER_NAME = "Imprudence"; const S32 IMP_VERSION_MAJOR = 1; const S32 IMP_VERSION_MINOR = 1; const S32 IMP_VERSION_PATCH = 0; -const char * const IMP_VERSION_TEST = "RC1"; +const char * const IMP_VERSION_TEST = "BB1"; #endif diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 72d8f17..b533f02 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -35,6 +35,7 @@ #include "lltexteditor.h" +#include "llerror.h" #include "llfontgl.h" #include "llrender.h" #include "llui.h" @@ -57,6 +58,7 @@ #include "llimagegl.h" #include "llwindow.h" #include +#include // // Globals @@ -4324,19 +4326,23 @@ BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const *end = findHTMLToken(line, m1, FALSE); //Load_url only handles http and https so don't hilite ftp, smb, etc. - m2 = line.substr(*begin,(m1 - *begin)).find("http"); - m3 = line.substr(*begin,(m1 - *begin)).find("secondlife"); - - std::string badneighbors=".,<>?';\"][}{=-+_)(*&^%$#@!~`\t\r\n\\"; - - if (m2 >= 0 || m3>=0) - { + try { + m2 = line.substr(*begin,(m1 - *begin)).find("http"); + m3 = line.substr(*begin,(m1 - *begin)).find("secondlife"); + + std::string badneighbors=".,<>?';\"][}{=-+_)(*&^%$#@!~`\t\r\n\\"; + + if (m2 >= 0 || m3>=0) + { S32 bn = badneighbors.find(line.substr(m1+3,1)); - + if (bn < 0) { - matched = TRUE; + matched = TRUE; } + } + } catch ( std::out_of_range outOfRange ) { + LL_WARNS("") << "LLTextEditor::findHTML() got std::out_of_range exception \"" << line << "\"" << LL_ENDL; } } /* matches things like secondlife.com (no http://) needs a whitelist to really be effective. @@ -4369,41 +4375,45 @@ BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const { S32 strpos, strpos2; - std::string url = line.substr(*begin,*end - *begin); - std::string slurlID = "slurl.com/secondlife/"; - strpos = url.find(slurlID); - - if (strpos < 0) - { + try { + std::string url = line.substr(*begin,*end - *begin); + std::string slurlID = "slurl.com/secondlife/"; + strpos = url.find(slurlID); + + if (strpos < 0) + { slurlID="secondlife://"; strpos = url.find(slurlID); - } - - if (strpos < 0) - { + } + + if (strpos < 0) + { slurlID="sl://"; strpos = url.find(slurlID); - } - - if (strpos >= 0) - { + } + + if (strpos >= 0) + { strpos+=slurlID.length(); - + while ( ( strpos2=url.find("/",strpos) ) == -1 ) { - if ((*end+2) >= (S32)line.length() || line.substr(*end,1) != " " ) - { - matched=FALSE; - break; - } - - strpos = (*end + 1) - *begin; - - *end = findHTMLToken(line,(*begin + strpos),FALSE); - url = line.substr(*begin,*end - *begin); + if ((*end+2) >= (S32)line.length() || line.substr(*end,1) != " " ) + { + matched=FALSE; + break; + } + + strpos = (*end + 1) - *begin; + + *end = findHTMLToken(line,(*begin + strpos),FALSE); + url = line.substr(*begin,*end - *begin); } - } + } + } catch ( std::out_of_range outOfRange ) { + LL_WARNS("") << "LLTextEditor::findHTML() got std::out_of_range exception \"" << line << "\"" << LL_ENDL; + } } if (!matched) -- 1.5.6.3