aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-07-15 21:40:44 +0100
committerJustin Clark-Casey (justincc)2010-07-26 23:34:21 +0100
commit664cbe2357cdb05202c01f1575f1e9f08273904e (patch)
treec932ca3dbdfd56ee7b2164c3a7e3615ce95a8ce6 /OpenSim
parentImplement * end wildcard for whitelist urls (diff)
downloadopensim-SC_OLD-664cbe2357cdb05202c01f1575f1e9f08273904e.zip
opensim-SC_OLD-664cbe2357cdb05202c01f1575f1e9f08273904e.tar.gz
opensim-SC_OLD-664cbe2357cdb05202c01f1575f1e9f08273904e.tar.bz2
opensim-SC_OLD-664cbe2357cdb05202c01f1575f1e9f08273904e.tar.xz
refactor: simplify current whitelist url checking by using System.Uri
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index c24e6d5..c8e72ca 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -451,11 +451,13 @@ namespace OpenSim.Region.CoreModules.Media.Moap
451 /// <summary> 451 /// <summary>
452 /// Check the given url against the given whitelist. 452 /// Check the given url against the given whitelist.
453 /// </summary> 453 /// </summary>
454 /// <param name="url"></param> 454 /// <param name="rawUrl"></param>
455 /// <param name="whitelist"></param> 455 /// <param name="whitelist"></param>
456 /// <returns>true if the url matches an entry on the whitelist, false otherwise</returns> 456 /// <returns>true if the url matches an entry on the whitelist, false otherwise</returns>
457 protected bool CheckUrlAgainstWhitelist(string url, string[] whitelist) 457 protected bool CheckUrlAgainstWhitelist(string rawUrl, string[] whitelist)
458 { 458 {
459 Uri url = new Uri(rawUrl);
460
459 foreach (string rawWlUrl in whitelist) 461 foreach (string rawWlUrl in whitelist)
460 { 462 {
461 string wlUrl = rawWlUrl; 463 string wlUrl = rawWlUrl;
@@ -464,14 +466,13 @@ namespace OpenSim.Region.CoreModules.Media.Moap
464 if (wlUrl.EndsWith("*")) 466 if (wlUrl.EndsWith("*"))
465 wlUrl = wlUrl.Remove(wlUrl.Length - 1); 467 wlUrl = wlUrl.Remove(wlUrl.Length - 1);
466 468
467 if (!wlUrl.StartsWith("http://"))
468 wlUrl = "http://" + wlUrl;
469
470 m_log.DebugFormat("[MOAP]: Checking whitelist URL {0}", wlUrl); 469 m_log.DebugFormat("[MOAP]: Checking whitelist URL {0}", wlUrl);
470
471 string urlToMatch = url.Authority + url.AbsolutePath;
471 472
472 if (url.StartsWith(wlUrl)) 473 if (urlToMatch.StartsWith(wlUrl))
473 { 474 {
474 m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", wlUrl, url); 475 m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", wlUrl, urlToMatch);
475 return true; 476 return true;
476 } 477 }
477 } 478 }