From 664cbe2357cdb05202c01f1575f1e9f08273904e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Jul 2010 21:40:44 +0100 Subject: refactor: simplify current whitelist url checking by using System.Uri --- OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') 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 /// /// Check the given url against the given whitelist. /// - /// + /// /// /// true if the url matches an entry on the whitelist, false otherwise - protected bool CheckUrlAgainstWhitelist(string url, string[] whitelist) + protected bool CheckUrlAgainstWhitelist(string rawUrl, string[] whitelist) { + Uri url = new Uri(rawUrl); + foreach (string rawWlUrl in whitelist) { string wlUrl = rawWlUrl; @@ -464,14 +466,13 @@ namespace OpenSim.Region.CoreModules.Media.Moap if (wlUrl.EndsWith("*")) wlUrl = wlUrl.Remove(wlUrl.Length - 1); - if (!wlUrl.StartsWith("http://")) - wlUrl = "http://" + wlUrl; - m_log.DebugFormat("[MOAP]: Checking whitelist URL {0}", wlUrl); + + string urlToMatch = url.Authority + url.AbsolutePath; - if (url.StartsWith(wlUrl)) + if (urlToMatch.StartsWith(wlUrl)) { - m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", wlUrl, url); + m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", wlUrl, urlToMatch); return true; } } -- cgit v1.1