diff --git a/Rest.Net/HttpListenerResponseExtensions.cs b/Rest.Net/HttpListenerResponseExtensions.cs index 4f76d09..a662947 100644 --- a/Rest.Net/HttpListenerResponseExtensions.cs +++ b/Rest.Net/HttpListenerResponseExtensions.cs @@ -666,9 +666,20 @@ namespace MontoyaTech.Rest.Net if (string.IsNullOrWhiteSpace(requestPath) || requestPath == "/" || requestPath == ".") requestPath = indexFile; + //See if there is a parent directory in the basePath, if so get it + var parentDirectory = basePath.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault(); + //Break the request path into it's components so we can enfore staying in the base path. var components = requestPath.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + //If the first component is the parent directory, then remove it + if (components.Count > 0 && components[0].Equals(parentDirectory, StringComparison.CurrentCultureIgnoreCase)) + components.RemoveAt(0); + + //Quirk, if the components is now empty, point to the indexFile + if (components.Count == 0) + components.Add(indexFile); + for (int i = 0; i < components.Count; i++) { if (components[i].Trim() == "..") diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index fc3550e..9c3467e 100644 --- a/Rest.Net/Rest.Net.csproj +++ b/Rest.Net/Rest.Net.csproj @@ -17,7 +17,7 @@ MontoyaTech.Rest.Net MontoyaTech.Rest.Net True - 1.6.4 + 1.6.5 Logo_Symbol_Black_Outline.png