[Mono-bugs] [Bug 53670][Nor] New - Encoding for UrlEncode and UrlPathEncode, and exception raised by UrlPathEncode for path w/o a '?'
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 firstname.lastname@example.org.
--- 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 @@
+Product: Mono/Class Libraries
+OS Details: Gentoo
+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);
+ s3 = Server.UrlPathEncode(s1);
+ s3 = "ERROR: Server.UrlPathEncode";
+Value to encode: <%= s1 %>
+URL Encoded: <%= s2 %>
+URL Path Encoded: <%= s3 %>
+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
+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?