Search code examples
javascriptfirefoxuriurl-encoding

Spaces in URIs in Firefox 7


In Firefox version 7.0.1, URIs with encoded spaces in them are automatically converted to a space in the Location Bar.

This does not happen in Internet Explorer.

For example, I have a textbox on a page with contents of "Test Test". I have a javascript function that reloads the page with the encoded contents of the textbox using encodeURIComponent().

Internet Explorer produces:

http://host/page.php?box=Test%20Test

Firefox 7.0.1 produces:

http://host/page.php?box=Test Test

Upon alerting out the results of encodeURIComponent in Firefox, the space is correctly escaped as %20.

It appears Firefox is doing something that is removing the encoding from the URI. This then results in the URI not conforming to RFC2396

My question is what should I as a developer do? In fact, do I need to do anything?


Solution

  • This applies only to the URL field that Firefox shows to the user, not the actual request that gets made.

    If you look at the request in Firefox 7 on Windows 7, you will see that the spaces get URL encoded:

    enter image description here