I think the current implementation of the JSON form is broken.
If you put an & in a text field and try to submit it via a JSON form
it doesn't get handled correctly.
To be precise the formToJSON function in jlift.js doesn't work, and
again to be more precise the params method is broken / not fit for
purpose.
The params method (line 249) calls s.join("&") and then returns but it
doesn't escape the & character (it also uses = but doesn't escape
that). If the params function does what I think it is supposed to do
which is split paramters for a URL then it should really call
encodeURI on the values.
That aside I don't think the formToJSON function should be using the
param function. It gets a JSON object from jQuery serializeArray makes
it into a string split by & and = then goes and splits based on & and
= again building up some JSON (as a string) then parses the JSON. Why
not operate on the JSON from jQuery from the start.
e.g.
formToJSON : function(formId)
{
json = jQuery("#" + formId).serializeArray();
ret = {}
for (var i in json)
{
var obj = json[i]
ret[obj.name] = obj.value
}
return ret;
}
This does work differently from before since it won't call functions
like params does but I don't think jQuery's serializeArray puts
functions in the object it returns so that is not needed.
James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---