diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-08-29 04:09:08 +0400 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-08-29 04:09:08 +0400 |
commit | 26fe2a737e4020318ae9c0a0fa9e50e2dd293a4d (patch) | |
tree | 777340456ff074b2f7165a406ce6a07af20d9d70 /mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs | |
parent | 52f615c07accdaa9fa505981dcdd696622e24f58 (diff) |
2003-08-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* SimpleWorkerRequest.cs: fixed GetFilePathTranslated and added a
paranoid condition to ExtractPathInfo.
svn path=/trunk/mcs/; revision=17712
Diffstat (limited to 'mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs')
-rw-r--r-- | mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs b/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs index 4591e038e92..6267f54361d 100644 --- a/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs +++ b/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs @@ -124,10 +124,11 @@ namespace System.Web.Hosting string page = _Page; if (Path.DirectorySeparatorChar != '/') - { page = _Page.Replace ('/', Path.DirectorySeparatorChar); - } + if (page [0] == Path.DirectorySeparatorChar) + page = page.Substring (1); + return (Path.Combine (_AppPhysicalPath, page)); } @@ -274,56 +275,45 @@ namespace System.Web.Hosting return sPath; } - // "The extra path information, as given by the client. In - // other words, scripts can be accessed by their virtual - // pathname, followed by extra information at the end of this - // path. The extra information is sent as PATH_INFO." - private void ExtractPagePathInfo () - { - if (_Page == null || _Page == String.Empty) - { - return; - } + // "The extra path information, as given by the client. In + // other words, scripts can be accessed by their virtual + // pathname, followed by extra information at the end of this + // path. The extra information is sent as PATH_INFO." + private void ExtractPagePathInfo () + { + if (_Page == null || _Page == String.Empty) + return; - string FullPath = GetFilePathTranslated(); + string FullPath = GetFilePathTranslated (); + int PathInfoLength = 0; + string LastFile = String.Empty; - int PathInfoLength = 0; + while (PathInfoLength < _Page.Length) { + if (LastFile.Length > 0) { + // increase it by the length of the file plus + // a "/" + // + PathInfoLength += LastFile.Length + 1; + } - string LastFile = String.Empty; + if (File.Exists (FullPath) == true) + break; - while (PathInfoLength < _Page.Length) - { - if (LastFile.Length > 0) - { - // increase it by the length of the file plus - // a "/" - // - PathInfoLength += LastFile.Length + 1; - } - - if (File.Exists (FullPath) == true) - { - break; - } - - if (Directory.Exists (FullPath) == true) - { - PathInfoLength -= (LastFile.Length + 1); - break; - } - - LastFile = Path.GetFileName (FullPath); - FullPath = Path.GetDirectoryName (FullPath); - } + if (Directory.Exists (FullPath) == true) { + PathInfoLength -= (LastFile.Length + 1); + break; + } - if (PathInfoLength > _Page.Length) - { - return; - } + LastFile = Path.GetFileName (FullPath); + FullPath = Path.GetDirectoryName (FullPath); + } + + if (PathInfoLength <= 0 || PathInfoLength > _Page.Length) + return; - _PathInfo = _Page.Substring (_Page.Length - PathInfoLength); - _Page = _Page.Substring (0, _Page.Length - PathInfoLength); - } + _PathInfo = _Page.Substring (_Page.Length - PathInfoLength); + _Page = _Page.Substring (0, _Page.Length - PathInfoLength); + } } } |