From 0bec4f5ea5b2586bcc3899ad084e30d42218cb44 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Jul 2010 21:51:57 +0100 Subject: Handle checking of line starting "*" wildcard for whitelist patterns A line starting * can only be applied to the domain, not the path --- .../CoreModules/World/Media/Moap/MoapModule.cs | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index c8e72ca..cbe9af2 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -458,22 +458,36 @@ namespace OpenSim.Region.CoreModules.Media.Moap { Uri url = new Uri(rawUrl); - foreach (string rawWlUrl in whitelist) + foreach (string origWlUrl in whitelist) { - string wlUrl = rawWlUrl; + string wlUrl = origWlUrl; // Deal with a line-ending wildcard if (wlUrl.EndsWith("*")) wlUrl = wlUrl.Remove(wlUrl.Length - 1); - m_log.DebugFormat("[MOAP]: Checking whitelist URL {0}", wlUrl); + m_log.DebugFormat("[MOAP]: Checking whitelist URL pattern {0}", origWlUrl); - string urlToMatch = url.Authority + url.AbsolutePath; - - if (urlToMatch.StartsWith(wlUrl)) + // Handle a line starting wildcard slightly differently since this can only match the domain, not the path + if (wlUrl.StartsWith("*")) + { + wlUrl = wlUrl.Substring(1); + + if (url.Host.Contains(wlUrl)) + { + m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", origWlUrl, rawUrl); + return true; + } + } + else { - m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", wlUrl, urlToMatch); - return true; + string urlToMatch = url.Authority + url.AbsolutePath; + + if (urlToMatch.StartsWith(wlUrl)) + { + m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", origWlUrl, rawUrl); + return true; + } } } -- cgit v1.1