aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/hippoGridManager.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-09-23 22:40:53 -0500
committerJacek Antonelli2009-09-25 22:59:42 -0500
commit35f17c2ce6b972177ccdd182a9587ed2af61a6f9 (patch)
tree677ae3a2bcf94baa7109c7405f2e7217243fd093 /linden/indra/newview/hippoGridManager.cpp
parentMoved many HippoGridManager methods defs out of the header. (diff)
downloadmeta-impy-35f17c2ce6b972177ccdd182a9587ed2af61a6f9.zip
meta-impy-35f17c2ce6b972177ccdd182a9587ed2af61a6f9.tar.gz
meta-impy-35f17c2ce6b972177ccdd182a9587ed2af61a6f9.tar.bz2
meta-impy-35f17c2ce6b972177ccdd182a9587ed2af61a6f9.tar.xz
Made HippoGridManager's sanitation code more sane.
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/hippoGridManager.cpp52
1 files changed, 29 insertions, 23 deletions
diff --git a/linden/indra/newview/hippoGridManager.cpp b/linden/indra/newview/hippoGridManager.cpp
index ffac92d..485be20 100644
--- a/linden/indra/newview/hippoGridManager.cpp
+++ b/linden/indra/newview/hippoGridManager.cpp
@@ -38,13 +38,13 @@ HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO("");
38 38
39HippoGridInfo::HippoGridInfo(const std::string &gridNick) : 39HippoGridInfo::HippoGridInfo(const std::string &gridNick) :
40 mPlatform(PLATFORM_OTHER), 40 mPlatform(PLATFORM_OTHER),
41 mGridNick(gridNick),
42 mRenderCompat(true), 41 mRenderCompat(true),
43 mCurrencySymbol("OS$"), 42 mCurrencySymbol("OS$"),
44 mRealCurrencySymbol("US$"), 43 mRealCurrencySymbol("US$"),
45 mDirectoryFee(30) 44 mDirectoryFee(30)
46{ 45{
47 cleanUpGridNick(mGridNick); 46 std::string nick = gridNick;
47 mGridNick = sanitizeGridNick( nick );
48} 48}
49 49
50 50
@@ -181,8 +181,8 @@ void HippoGridInfo::setGridName(const std::string &gridName)
181 181
182void HippoGridInfo::setLoginUri(const std::string &loginUri) 182void HippoGridInfo::setLoginUri(const std::string &loginUri)
183{ 183{
184 mLoginUri = loginUri; 184 std::string uri = loginUri;
185 cleanUpUri(mLoginUri); 185 mLoginUri = sanitizeUri(uri);
186} 186}
187 187
188void HippoGridInfo::setLoginPage(const std::string &loginPage) 188void HippoGridInfo::setLoginPage(const std::string &loginPage)
@@ -192,8 +192,8 @@ void HippoGridInfo::setLoginPage(const std::string &loginPage)
192 192
193void HippoGridInfo::setHelperUri(const std::string &helperUri) 193void HippoGridInfo::setHelperUri(const std::string &helperUri)
194{ 194{
195 mHelperUri = helperUri; 195 std::string uri = helperUri;
196 cleanUpUri(mHelperUri); 196 mHelperUri = sanitizeUri(uri);
197} 197}
198 198
199void HippoGridInfo::setWebSite(const std::string &website) 199void HippoGridInfo::setWebSite(const std::string &website)
@@ -332,10 +332,11 @@ void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int le
332 HippoGridInfo *self = (HippoGridInfo*)userData; 332 HippoGridInfo *self = (HippoGridInfo*)userData;
333 switch (self->mXmlState) { 333 switch (self->mXmlState) {
334 334
335 case XML_GRIDNICK: 335 case XML_GRIDNICK: {
336 if (self->mGridNick == "") self->mGridNick.assign(s, len); 336 if (self->mGridNick == "") self->mGridNick.assign(s, len);
337 cleanUpGridNick(self->mGridNick); 337 self->mGridNick = sanitizeGridNick(self->mGridNick);
338 break; 338 break;
339 }
339 340
340 case XML_PLATFORM: { 341 case XML_PLATFORM: {
341 std::string platform(s, len); 342 std::string platform(s, len);
@@ -343,26 +344,29 @@ void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int le
343 break; 344 break;
344 } 345 }
345 346
346 case XML_LOGINURI: 347 case XML_LOGINURI: {
347 self->mLoginUri.assign(s, len); 348 std::string loginuri(s, len);
348 cleanUpUri(self->mLoginUri); 349 self->mLoginUri = sanitizeUri( loginuri );
349 break; 350 break;
351 }
350 352
351 case XML_HELPERURI: 353 case XML_HELPERURI: {
352 self->mHelperUri.assign(s, len); 354 std::string helperuri(s, len);
353 cleanUpUri(self->mHelperUri); 355 self->mHelperUri = sanitizeUri( helperuri );
354 break; 356 break;
357 }
355 358
356 case XML_SEARCH: 359 case XML_SEARCH: {
357 //self->mSearchUrl.assign(s, len); 360 //self->mSearchUrl.assign(s, len);
358 //cleanUpQueryUrl(mSearchUrl); 361 //sanitizeQueryUrl(mSearchUrl);
359 break; 362 break;
363 }
360 364
361 case XML_GRIDNAME: self->mGridName.assign(s, len); break; 365 case XML_GRIDNAME: self->mGridName.assign(s, len); break;
362 case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; 366 case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break;
363 case XML_WEBSITE: self->mWebSite.assign(s, len); break; 367 case XML_WEBSITE: self->mWebSite.assign(s, len); break;
364 case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; 368 case XML_SUPPORT: self->mSupportUrl.assign(s, len); break;
365 case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; 369 case XML_REGISTER: self->mRegisterUrl.assign(s, len); break;
366 case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; 370 case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break;
367 371
368 case XML_VOID: break; 372 case XML_VOID: break;
@@ -445,7 +449,7 @@ const char *HippoGridInfo::getPlatformString(Platform platform)
445 449
446 450
447// static 451// static
448void HippoGridInfo::cleanUpGridNick(std::string &gridnick) 452std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick)
449{ 453{
450 std::string tmp; 454 std::string tmp;
451 int size = gridnick.size(); 455 int size = gridnick.size();
@@ -457,20 +461,22 @@ void HippoGridInfo::cleanUpGridNick(std::string &gridnick)
457 tmp += "_"; 461 tmp += "_";
458 } 462 }
459 } 463 }
460 gridnick = tmp; 464 return tmp;
461} 465}
462 466
463// static 467// static
464void HippoGridInfo::cleanUpUri(std::string &uri) 468std::string HippoGridInfo::sanitizeUri(std::string &uri)
465{ 469{
466 if (uri.empty()) { 470 if (uri.empty()) {
467 return; 471 return "";
468 } 472 }
469 473
470 // If last character in uri is not "/" 474 // If last character in uri is not "/"
471 if (uri.compare(uri.length()-1, 1, "/") != 0) { 475 if (uri.compare(uri.length()-1, 1, "/") != 0) {
472 uri += '/'; 476 return uri + '/';
473 } 477 }
478
479 return uri;
474} 480}
475 481
476 482