I'm curious as to why we have this function floating around in the first
place.  Isn't this something best done by a JavaScript library that has been
tested cross browser (e.g., something in jQuery or YUI)?
Also, doesn't the param function hardcode a dependency on jQuery... and
we're support to be agnostic about the JavaScript library that we sit on?

On Fri, Jul 31, 2009 at 3:34 AM, James Kearney <ghostf...@googlemail.com>wrote:

>
> I have had a look at the change, while better than the old one it
> still causes problems if you use a " in a text box because you are
> building JSON as a string and then parsing it.
>
> In my example code you go from a javascript object to another one
> there is no need for parsing so you don't run into problems with
> escape characters.
>
> I don't know if you are building the JSON as a string then parsing it
> for compatibility reasons if so you should escape any " found in the
> name and value.
> e.g.
> json += "\"" + e.name.replace(/\"/g,"\\\"") + "\":\"" + e.value.replace
> (/\"/g,"\\\"") + "\",";
>
>
> James
>
> On Jul 30, 6:14 pm, "marius d." <marius.dan...@gmail.com> wrote:
> > James,
> >
> > I just committed the fix based on your approach. Please give it a try.
> >
> > Br's,
> > Marius
> >
> > On Jul 30, 4:53 pm, "marius d." <marius.dan...@gmail.com> wrote:
> >
> > > Thank you James for your input. I hope I'll be able to look into it
> > > today.
> >
> > > Br's,
> > > Marius
> >
> > > On Jul 30, 4:42 pm, James Kearney <ghostf...@googlemail.com> wrote:
> >
> > > > 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
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to