[Mono-bugs] [Bug 56802][Nor] New - [PATCH] HttpRequest.MapPath is stripping trailing "/" on return
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 10 Apr 2004 21:59:24 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by vladimir@pobox.com.
http://bugzilla.ximian.com/show_bug.cgi?id=56802
--- shadow/56802 2004-04-10 21:59:24.000000000 -0400
+++ shadow/56802.tmp.30281 2004-04-10 21:59:24.000000000 -0400
@@ -0,0 +1,56 @@
+Bug#: 56802
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Web
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: vladimir@pobox.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: [PATCH] HttpRequest.MapPath is stripping trailing "/" on return
+
+If HttpRequest.MapPath is passed a path that has a trailing "/", on windows
+it seems to return a path with a trailing "/". Under mono, that trailing
+slash is silently stripped. This is the hacky patch that I'm using to get
+around it; it's probably not ideal:
+
+Index: HttpRequest.cs
+===================================================================
+RCS file: /cvs/public/mcs/class/System.Web/System.Web/HttpRequest.cs,v
+retrieving revision 1.46
+diff -u -u -w -r1.46 HttpRequest.cs
+--- HttpRequest.cs 25 Mar 2004 12:30:25 -0000 1.46
++++ HttpRequest.cs 11 Apr 2004 01:11:29 -0000
+@@ -1097,6 +1097,7 @@
+
+ public string MapPath (string virtualPath, string baseVirtualDir, bool
+allowCrossAppMapping)
+ {
++ bool hasTrailingSlash = virtualPath.EndsWith("/");
+ if (_WorkerRequest == null)
+ throw new HttpException ("No HttpWorkerRequest!!!");
+
+@@ -1113,12 +1114,16 @@
+
+ if (UrlUtils.IsRooted (virtualPath)) {
+ virtualPath = UrlUtils.Reduce (virtualPath);
++ if (!virtualPath.EndsWith("/") && hasTrailingSlash)
++ virtualPath += "/";
+ } else {
+ if (baseVirtualDir == null) {
+ virtualPath = UrlUtils.Combine (RootVirtualDir, virtualPath);
+ } else {
+ virtualPath = UrlUtils.Combine (baseVirtualDir, virtualPath);
+ }
++ if (!virtualPath.EndsWith("/") && hasTrailingSlash)
++ virtualPath += "/";
+ }
+
+ if (!allowCrossAppMapping) {