diff options
author | Justin Clark-Casey (justincc) | 2010-07-15 21:51:57 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-26 23:34:21 +0100 |
commit | cd985ab71b489d63d9f1033b5159f207ab614b18 (patch) | |
tree | c156a1443a4187f068d2dc1c7410e5d16c072e8a | |
parent | refactor: simplify current whitelist url checking by using System.Uri (diff) | |
download | opensim-SC_OLD-cd985ab71b489d63d9f1033b5159f207ab614b18.zip opensim-SC_OLD-cd985ab71b489d63d9f1033b5159f207ab614b18.tar.gz opensim-SC_OLD-cd985ab71b489d63d9f1033b5159f207ab614b18.tar.bz2 opensim-SC_OLD-cd985ab71b489d63d9f1033b5159f207ab614b18.tar.xz |
Handle checking of line starting "*" wildcard for whitelist patterns
A line starting * can only be applied to the domain, not the path
-rw-r--r-- | OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 30 |
1 files changed, 22 insertions, 8 deletions
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 | |||
458 | { | 458 | { |
459 | Uri url = new Uri(rawUrl); | 459 | Uri url = new Uri(rawUrl); |
460 | 460 | ||
461 | foreach (string rawWlUrl in whitelist) | 461 | foreach (string origWlUrl in whitelist) |
462 | { | 462 | { |
463 | string wlUrl = rawWlUrl; | 463 | string wlUrl = origWlUrl; |
464 | 464 | ||
465 | // Deal with a line-ending wildcard | 465 | // Deal with a line-ending wildcard |
466 | if (wlUrl.EndsWith("*")) | 466 | if (wlUrl.EndsWith("*")) |
467 | wlUrl = wlUrl.Remove(wlUrl.Length - 1); | 467 | wlUrl = wlUrl.Remove(wlUrl.Length - 1); |
468 | 468 | ||
469 | m_log.DebugFormat("[MOAP]: Checking whitelist URL {0}", wlUrl); | 469 | m_log.DebugFormat("[MOAP]: Checking whitelist URL pattern {0}", origWlUrl); |
470 | 470 | ||
471 | string urlToMatch = url.Authority + url.AbsolutePath; | 471 | // Handle a line starting wildcard slightly differently since this can only match the domain, not the path |
472 | 472 | if (wlUrl.StartsWith("*")) | |
473 | if (urlToMatch.StartsWith(wlUrl)) | 473 | { |
474 | wlUrl = wlUrl.Substring(1); | ||
475 | |||
476 | if (url.Host.Contains(wlUrl)) | ||
477 | { | ||
478 | m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", origWlUrl, rawUrl); | ||
479 | return true; | ||
480 | } | ||
481 | } | ||
482 | else | ||
474 | { | 483 | { |
475 | m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", wlUrl, urlToMatch); | 484 | string urlToMatch = url.Authority + url.AbsolutePath; |
476 | return true; | 485 | |
486 | if (urlToMatch.StartsWith(wlUrl)) | ||
487 | { | ||
488 | m_log.DebugFormat("[MOAP]: Whitelist URL {0} matches {1}", origWlUrl, rawUrl); | ||
489 | return true; | ||
490 | } | ||
477 | } | 491 | } |
478 | } | 492 | } |
479 | 493 | ||