aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-02-14 02:03:41 -0700
committerMcCabe Maxsted2009-02-14 02:03:41 -0700
commit96b0263ed0955d11eb0db700bb770958a5436711 (patch)
tree90992f98985113ac3ca50e325404554bbf9996d8
parentRemoved search for non-existant floater_preview_new_landmark.xml (diff)
downloadmeta-impy-96b0263ed0955d11eb0db700bb770958a5436711.zip
meta-impy-96b0263ed0955d11eb0db700bb770958a5436711.tar.gz
meta-impy-96b0263ed0955d11eb0db700bb770958a5436711.tar.bz2
meta-impy-96b0263ed0955d11eb0db700bb770958a5436711.tar.xz
Fixed crash in LLTextEditor::findHTML
-rw-r--r--ChangeLog.txt5
-rw-r--r--linden/indra/llui/lltexteditor.cpp111
2 files changed, 71 insertions, 45 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 457e9ab..a0eb214 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -18,6 +18,11 @@
18 Removed search for non-existant floater_preview_new_landmark.xml. 18 Removed search for non-existant floater_preview_new_landmark.xml.
19 19
20 20
21 Anders Arnholm <anders@arnholm.se>
22 * linden/indra/llui/lltexteditor.cpp:
23 Fixed crash in LLTextEditor::findHTML
24
25
212009-02-04 McCabe Maxsted <hakushakukun@gmail.com> 262009-02-04 McCabe Maxsted <hakushakukun@gmail.com>
22 27
23 * linden/indra/cmake/CopyWinLibs.cmake: 28 * linden/indra/cmake/CopyWinLibs.cmake:
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp
index 72d8f17..714ee7c 100644
--- a/linden/indra/llui/lltexteditor.cpp
+++ b/linden/indra/llui/lltexteditor.cpp
@@ -35,6 +35,7 @@
35 35
36#include "lltexteditor.h" 36#include "lltexteditor.h"
37 37
38#include "llerror.h"
38#include "llfontgl.h" 39#include "llfontgl.h"
39#include "llrender.h" 40#include "llrender.h"
40#include "llui.h" 41#include "llui.h"
@@ -57,6 +58,7 @@
57#include "llimagegl.h" 58#include "llimagegl.h"
58#include "llwindow.h" 59#include "llwindow.h"
59#include <queue> 60#include <queue>
61#include <stdexcept>
60 62
61// 63//
62// Globals 64// Globals
@@ -3537,6 +3539,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text,
3537 std::string text = new_text; 3539 std::string text = new_text;
3538 while ( findHTML(text, &start, &end) ) 3540 while ( findHTML(text, &start, &end) )
3539 { 3541 {
3542
3540 LLStyleSP html(new LLStyle); 3543 LLStyleSP html(new LLStyle);
3541 html->setVisible(true); 3544 html->setVisible(true);
3542 html->setColor(mLinkColor); 3545 html->setColor(mLinkColor);
@@ -3624,10 +3627,6 @@ void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool
3624 { 3627 {
3625 mSelectionStart = selection_start; 3628 mSelectionStart = selection_start;
3626 mSelectionEnd = selection_end; 3629 mSelectionEnd = selection_end;
3627
3628
3629
3630
3631 mIsSelecting = was_selecting; 3630 mIsSelecting = was_selecting;
3632 setCursorPos(cursor_pos); 3631 setCursorPos(cursor_pos);
3633 } 3632 }
@@ -4272,6 +4271,7 @@ S32 LLTextEditor::findHTMLToken(const std::string &line, S32 pos, BOOL reverse)
4272 return index+1; 4271 return index+1;
4273 } 4272 }
4274 } 4273 }
4274 index = 0; // Can't be before first charater
4275 } 4275 }
4276 else 4276 else
4277 { 4277 {
@@ -4322,21 +4322,34 @@ BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const
4322 { 4322 {
4323 *begin = findHTMLToken(line, m1, TRUE); 4323 *begin = findHTMLToken(line, m1, TRUE);
4324 *end = findHTMLToken(line, m1, FALSE); 4324 *end = findHTMLToken(line, m1, FALSE);
4325
4326 // Can't start before the first char
4327 if(*begin < 0)
4328 {
4329 //*begin = 0;
4330 }
4325 4331
4326 //Load_url only handles http and https so don't hilite ftp, smb, etc. 4332 //Load_url only handles http and https so don't hilite ftp, smb, etc.
4327 m2 = line.substr(*begin,(m1 - *begin)).find("http"); 4333 try
4328 m3 = line.substr(*begin,(m1 - *begin)).find("secondlife");
4329
4330 std::string badneighbors=".,<>?';\"][}{=-+_)(*&^%$#@!~`\t\r\n\\";
4331
4332 if (m2 >= 0 || m3>=0)
4333 { 4334 {
4334 S32 bn = badneighbors.find(line.substr(m1+3,1)); 4335 m2 = line.substr(*begin,(m1 - *begin)).find("http");
4335 4336 m3 = line.substr(*begin,(m1 - *begin)).find("secondlife");
4336 if (bn < 0) 4337
4337 { 4338 std::string badneighbors=".,<>?';\"][}{=-+_)(*&^%$#@!~`\t\r\n\\";
4338 matched = TRUE; 4339
4340 if (m2 >= 0 || m3>=0)
4341 {
4342 S32 bn = badneighbors.find(line.substr(m1+3,1));
4343
4344 if (bn < 0)
4345 {
4346 matched = TRUE;
4347 }
4339 } 4348 }
4349 }
4350 catch ( std::out_of_range outOfRange )
4351 {
4352 LL_WARNS("TextEditor") << "got std::out_of_range exception \"" << line << "\"" << LL_ENDL;
4340 } 4353 }
4341 } 4354 }
4342/* matches things like secondlife.com (no http://) needs a whitelist to really be effective. 4355/* matches things like secondlife.com (no http://) needs a whitelist to really be effective.
@@ -4369,41 +4382,49 @@ BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const
4369 { 4382 {
4370 S32 strpos, strpos2; 4383 S32 strpos, strpos2;
4371 4384
4372 std::string url = line.substr(*begin,*end - *begin); 4385 try
4373 std::string slurlID = "slurl.com/secondlife/";
4374 strpos = url.find(slurlID);
4375
4376 if (strpos < 0)
4377 { 4386 {
4378 slurlID="secondlife://"; 4387 std::string url = line.substr(*begin,*end - *begin);
4379 strpos = url.find(slurlID); 4388 std::string slurlID = "slurl.com/secondlife/";
4380 } 4389 strpos = url.find(slurlID);
4381 4390
4382 if (strpos < 0) 4391 if (strpos < 0)
4383 { 4392 {
4384 slurlID="sl://"; 4393 slurlID="secondlife://";
4385 strpos = url.find(slurlID); 4394 strpos = url.find(slurlID);
4386 } 4395 }
4387 4396
4388 if (strpos >= 0) 4397 if (strpos < 0)
4389 { 4398 {
4390 strpos+=slurlID.length(); 4399 slurlID="sl://";
4391 4400 strpos = url.find(slurlID);
4392 while ( ( strpos2=url.find("/",strpos) ) == -1 ) 4401 }
4393 { 4402
4394 if ((*end+2) >= (S32)line.length() || line.substr(*end,1) != " " ) 4403 if (strpos >= 0)
4404 {
4405 strpos+=slurlID.length();
4406
4407 while ( ( strpos2=url.find("/",strpos) ) == -1 )
4395 { 4408 {
4396 matched=FALSE; 4409 if ((*end+2) >= (S32)line.length() || line.substr(*end,1) != " " )
4397 break; 4410 {
4411 matched=FALSE;
4412 break;
4413 }
4414
4415 strpos = (*end + 1) - *begin;
4416
4417 *end = findHTMLToken(line,(*begin + strpos),FALSE);
4418 url = line.substr(*begin,*end - *begin);
4398 } 4419 }
4399 4420 }
4400 strpos = (*end + 1) - *begin; 4421
4401
4402 *end = findHTMLToken(line,(*begin + strpos),FALSE);
4403 url = line.substr(*begin,*end - *begin);
4404 }
4405 } 4422 }
4406 4423
4424 catch ( std::out_of_range outOfRange )
4425 {
4426 LL_WARNS("TextEditor") << "got std::out_of_range exception \"" << line << "\"" << LL_ENDL;
4427 }
4407 } 4428 }
4408 4429
4409 if (!matched) 4430 if (!matched)