[Mono-bugs] [Bug 53670][Nor] New - Encoding for UrlEncode and UrlPathEncode, and exception raised by UrlPathEncode for path w/o a '?'

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 31 Jan 2004 09:40:41 -0500 (EST)


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 mmorano@mikeandwan.us.

http://bugzilla.ximian.com/show_bug.cgi?id=53670

--- shadow/53670	2004-01-31 09:40:41.000000000 -0500
+++ shadow/53670.tmp.32025	2004-01-31 09:40:41.000000000 -0500
@@ -0,0 +1,86 @@
+Bug#: 53670
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: Gentoo
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Web
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mmorano@mikeandwan.us               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Encoding for UrlEncode and UrlPathEncode, and exception raised by UrlPathEncode for path w/o a '?'
+
+Description of Problem:
+I am using mono0.29 and mod_mono0.6.  I have a website which has a control
+to list the contents of a directory, where each file in the directory will
+be displayed as a link for the user to click.  The problem I am having is
+that some of these files have spaces in them, and when I try to UrlEncode
+them using HttpServerUtility, space characters are encoded with '+' characters.
+
+This _does_ work in xsp0.8, and it happily finds the file the user clicks
+on.  However, in mod_mono through apache, it does not find these files.  
+
+I then attempted to use UrlPathEncode, and this failed because the file
+does not  have a querystring associated to it.  The code tries to find the
+index of the '?' and then takes the substring from the start to this
+position, however, in the case of a url w/o a querystring, this would be a
+call to substring(0, -1) which then throws an Argument out of range exception.
+
+Additionally, the escaping of the path should use the %XX escape scheme,
+such as %20 for a space.  Perhaps this is what is tripping up apache/mod_mono.
+
+Steps to reproduce the problem:
+1. access the following page:
+
+<%@ page language="c#" %>
+<%
+string s1 = "http://localhost/My File Contains A Space.txt";
+
+string s2 = Server.UrlEncode(s1);
+
+string s3;
+
+try {
+  s3 = Server.UrlPathEncode(s1);
+}
+catch(Exception e)
+{
+  s3 = "ERROR: Server.UrlPathEncode";
+}
+
+%>
+
+Value to encode: <%= s1 %>
+<p/>
+URL Encoded: <%= s2 %>
+<p/>
+URL Path Encoded: <%= s3 %>
+
+
+
+Actual Results:
+(using xsp0.8)
+Value to encode: http://localhost/My File Contains A Space.txt
+
+URL Encoded: http%3A%2F%2Flocalhost%2FMy+File+Contains+A+Space.txt
+
+URL Path Encoded: ERROR: Server.UrlPathEncode
+
+
+
+Expected Results:
+The URL Encoding would use %20 escape sequences for spaces, not '+' characters.
+
+No exception would be thrown calling UrlPathEncode() with a string that
+does not contain a querystring ('?')
+
+How often does this happen? 
+always
+
+Additional Information: