Maheshjayachandran / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.Uri.QueryData.toString doesn't handle empty string values properly #422

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?

<script>
var data = {
   foo:"bar",
   bar:""
}

var params = goog.Uri.QueryData.createFromMap(new goog.structs.Map( data ));

var str = params.toString();
alert(str);
</script>

What is the expected output? 

"foo=bar&bar="

What do you see instead?
"foo=bar&bar"

On Apache Apache/2.2.14 / PHP 5.1.3, the "bar" query parameter does not end up 
in the $_POST or $_REQUEST variables when doing AJAX calls without the trailing 
"=" sign.

What version of the product are you using? On what operating system?
I have no idea what the version is. I've looked all through the closure library 
code, and can't find a version number. It would be really cool if you could 
stamp it somewhere, maybe in the README. I can tell you that I updated to the 
latest version about a month ago.

Please provide any additional information below.
Troublesome code seems to be line 1477 of uri.js.

Original issue reported on code.google.com by max.l...@gmail.com on 12 Feb 2012 at 9:31

GoogleCodeExporter commented 9 years ago
This is working as designed. I can't find a link at the moment, but there was a 
long discussion about this, and it was consistent with how some java libraries 
work. see:
http://en.wikipedia.org/wiki/Query_string

Original comment by Nicholas.J.Santos on 28 Feb 2012 at 1:14

GoogleCodeExporter commented 9 years ago
Hmm, interesting. But I don't understand why you went with no-equals. If you 
use the equals, it won't harm or make any difference to people who can get 
along without it, but those of us who work with servers that depend on it are 
left having to write hacks and  workarounds. But is it even necessary for you 
to choose one way or the other? Why not provide an optional argument in there 
somewhere that defaults to no-equals-for-empty-string, but can be set the other 
way for those of us who need it? Surely that's reasonable? Thanks much.

Original comment by max.l...@gmail.com on 28 Feb 2012 at 10:43