mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
Better string matching when searching for REST handlers: must match an entire path component (ending with '/' or a similar character).
For example, these should match: "/assets" and "/assets/12345", but these shouldn't match: "/assets" and "/assets_exist".
This commit is contained in:
@@ -857,6 +857,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string HANDLER_SEPARATORS = "/?&#";
|
||||
|
||||
private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler)
|
||||
{
|
||||
string bestMatch = null;
|
||||
@@ -865,7 +867,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
foreach (string pattern in m_streamHandlers.Keys)
|
||||
{
|
||||
if (handlerKey.StartsWith(pattern))
|
||||
if ((handlerKey == pattern)
|
||||
|| (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0)))
|
||||
{
|
||||
if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
|
||||
{
|
||||
@@ -895,7 +898,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
foreach (string pattern in m_pollHandlers.Keys)
|
||||
{
|
||||
if (handlerKey.StartsWith(pattern))
|
||||
if ((handlerKey == pattern)
|
||||
|| (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0)))
|
||||
{
|
||||
if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
|
||||
{
|
||||
@@ -927,7 +931,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
foreach (string pattern in m_HTTPHandlers.Keys)
|
||||
{
|
||||
if (handlerKey.StartsWith(pattern))
|
||||
if ((handlerKey == pattern)
|
||||
|| (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0)))
|
||||
{
|
||||
if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user