diff options
author | Oren Hurvitz | 2014-04-02 08:52:44 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-04-02 08:52:44 +0300 |
commit | aa217cf90fbecf9334fc60d588968723ed17c351 (patch) | |
tree | d286ebcd9a403067a2990d96f2e4c0852f9e7118 /OpenSim | |
parent | Fixed last-resort sending of error response (HTTP 500) when an error occurs w... (diff) | |
download | opensim-SC_OLD-aa217cf90fbecf9334fc60d588968723ed17c351.zip opensim-SC_OLD-aa217cf90fbecf9334fc60d588968723ed17c351.tar.gz opensim-SC_OLD-aa217cf90fbecf9334fc60d588968723ed17c351.tar.bz2 opensim-SC_OLD-aa217cf90fbecf9334fc60d588968723ed17c351.tar.xz |
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".
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 7041181..e4a244e 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -857,6 +857,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
857 | } | 857 | } |
858 | } | 858 | } |
859 | 859 | ||
860 | private readonly string HANDLER_SEPARATORS = "/?&#"; | ||
861 | |||
860 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) | 862 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) |
861 | { | 863 | { |
862 | string bestMatch = null; | 864 | string bestMatch = null; |
@@ -865,7 +867,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
865 | { | 867 | { |
866 | foreach (string pattern in m_streamHandlers.Keys) | 868 | foreach (string pattern in m_streamHandlers.Keys) |
867 | { | 869 | { |
868 | if (handlerKey.StartsWith(pattern)) | 870 | if ((handlerKey == pattern) |
871 | || (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0))) | ||
869 | { | 872 | { |
870 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) | 873 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) |
871 | { | 874 | { |
@@ -895,7 +898,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
895 | { | 898 | { |
896 | foreach (string pattern in m_pollHandlers.Keys) | 899 | foreach (string pattern in m_pollHandlers.Keys) |
897 | { | 900 | { |
898 | if (handlerKey.StartsWith(pattern)) | 901 | if ((handlerKey == pattern) |
902 | || (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0))) | ||
899 | { | 903 | { |
900 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) | 904 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) |
901 | { | 905 | { |
@@ -927,7 +931,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
927 | { | 931 | { |
928 | foreach (string pattern in m_HTTPHandlers.Keys) | 932 | foreach (string pattern in m_HTTPHandlers.Keys) |
929 | { | 933 | { |
930 | if (handlerKey.StartsWith(pattern)) | 934 | if ((handlerKey == pattern) |
935 | || (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0))) | ||
931 | { | 936 | { |
932 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) | 937 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) |
933 | { | 938 | { |