aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-07-15 21:40:44 +0100
committerJustin Clark-Casey (justincc)2010-07-15 21:40:44 +0100
commit2ec6e3b4402ae7acf9e3f0da77c12203c2b44ff9 (patch)
treeec61950870a506ddc4ab53fa0ab42e7016b2b8d7
parentImplement * end wildcard for whitelist urls (diff)
downloadopensim-SC_OLD-2ec6e3b4402ae7acf9e3f0da77c12203c2b44ff9.zip
opensim-SC_OLD-2ec6e3b4402ae7acf9e3f0da77c12203c2b44ff9.tar.gz
opensim-SC_OLD-2ec6e3b4402ae7acf9e3f0da77c12203c2b44ff9.tar.bz2
opensim-SC_OLD-2ec6e3b4402ae7acf9e3f0da77c12203c2b44ff9.tar.xz
refactor: simplify current whitelist url checking by using System.Uri
-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 }