Bug 22557 - HttpValueCollection does not properly url encode values in ToString method
Summary: HttpValueCollection does not properly url encode values in ToString method
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: 3.4.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
Depends on:
Reported: 2014-09-02 00:27 UTC by Clinton Farleigh
Modified: 2014-10-07 17:07 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Clinton Farleigh 2014-09-02 00:27:08 UTC
I'm seeing an issue in mono (mono 3.4.0 running on Ubuntu 14.04 related to a difference in how mono vs. the microsoft .net runtime seems to be url encoding values in HttpValueCollection.ToString().

To show this difference:

        static void Main(string[] args)
            var queryStringNameValues = HttpUtility.ParseQueryString(string.Empty);
            queryStringNameValues.Add("ReturnUrl", @"http://localhost/login/authenticate?ReturnUrl=http://localhost/secured_area&__provider__=google");
            System.Console.WriteLine("HttpValueCollection to string = {0}", queryStringNameValues.ToString());

running in Microsoft .net runtime outputs:
HttpValueCollection to string = ReturnUrl=http%3a%2f%2flocalhost%2flogin%2fauthe

running in Mono (3.4.0) runtime outputs:
HttpValueCollection to string = ReturnUrl=http://localhost/login/authenticate?ReturnUrl=http://localhost/secured_area&__provider__=google

As you can see, the mono behavior leads to problems since the inner ReturnUrl and __provider__ parameters look to be parameters of the querystring generated by ToString() rather than querystring parameters of the URL contained in the value for the ReturnUrl key.
Comment 1 Rodrigo Kumpera 2014-10-03 08:35:59 UTC
Hey Marcos,

Could you take a look at this one?
Comment 2 marcos.henrich 2014-10-07 13:56:39 UTC
Hi Clinton,

Thank you for the detailed bug report.

The pull request for this issue can be found in the link below.
Comment 3 marcos.henrich 2014-10-07 17:07:41 UTC
Fixed in master c74ca498692cbbcb153040e0c2e5fd59cb8fce14.