Hi all, Just busted my head open on a problem with prototype Form.serialize. Case: An HTML form contains following form fields; <input name="isdn_invoice_lines.date" value="< 01/03/2007" type="text"> <input name="isdn_invoice_lines.date_time" value="< 01/03/2007" type="text"> <input name="isdn_invoice_lines.date_time" value="< 30/03/2007" type="text"> On submission the prototype Form.serialze is used to serialize before posting. Problem: When input types contain multiple values (multiple fields with the same name for instance) with special characters in them (like > or <) strange things start to happen. When the input is single value with special characters all is fine. Example serialized output: isdn_invoice_lines.date=%3C%2001%2F03%2F2007& isdn_invoice_lines.date_time=%253C%252001%252F03%252F2007& isdn_invoice_lines.date_time=%253C%252001%252F03%252F2007 I put in some linebreak for readabillity, this string is (ofcourse) one. The first field is encoded correctly. The other two fields have an extra ''25'' is added inside each encoded character, with the result that the server does not recognise it as url encoded and leaves it untouched. Further processing obviously results in various problems. My question now is if anyone bumped into this problem before and/or has found a solution for it. Thnx in advance. Regards, Martijn Teigeler --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Benjamin/Martijin Teigeler, I think your problem lies within having ampersands within the values, as this character is the delimiter from one key value pair and the next its going to always have huge problems in a query string. Try switching that to something else and I think you''ll have much better luck with data transmission. Cheers, Matt On Sep 5, 5:47 am, Benjamin <martijn.teige...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Just busted my head open on a problem with prototype Form.serialize. > > Case: > > An HTML form contains following form fields; > > <input name="isdn_invoice_lines.date" value="< 01/03/2007" > type="text"> > <input name="isdn_invoice_lines.date_time" value="< 01/03/2007" > type="text"> > <input name="isdn_invoice_lines.date_time" value="< 30/03/2007" > type="text"> > > On submission the prototype Form.serialze is used to serialize before > posting. > > Problem: > > When input types contain multiple values (multiple fields with the > same name for instance) with special characters in them (like > or > <) strange things start to happen. > > When the input is single value with special characters all is fine. > > Example serialized output: > > isdn_invoice_lines.date=%3C%2001%2F03%2F2007& > isdn_invoice_lines.date_time=%253C%252001%252F03%252F2007& > isdn_invoice_lines.date_time=%253C%252001%252F03%252F2007 > > I put in some linebreak for readabillity, this string is (ofcourse) > one. > > The first field is encoded correctly. The other two fields have an > extra ''25'' is added inside each encoded character, with the result > that the server does not recognise it as url encoded and leaves it > untouched. Further processing obviously results in various problems. > > My question now is if anyone bumped into this problem before and/or > has found a solution for it. > > Thnx in advance. > > Regards, > > Martijn Teigeler--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
i was thinking the same thing, but before even going that far... is the < necessary or is it just there for looks? are you using the < as part of a sql statement on the back end? basically what i''m getting at -- does the < need to be in the text or can you assume that if someone passes in text in whichever field that what they really want to do is a comparison of less than something else On 9/5/07, Matt Foster <mattfoster01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hey Benjamin/Martijin Teigeler, > > I think your problem lies within having ampersands within the > values, as this character is the delimiter from one key value pair and > the next its going to always have huge problems in a query string. > Try switching that to something else and I think you''ll have much > better luck with data transmission. > > Cheers, > Matt > > > On Sep 5, 5:47 am, Benjamin <martijn.teige...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all, > > > > Just busted my head open on a problem with prototype Form.serialize. > > > > Case: > > > > An HTML form contains following form fields; > > > > <input name="isdn_invoice_lines.date" value="< 01/03/2007" > > type="text"> > > <input name="isdn_invoice_lines.date_time" value="< 01/03/2007" > > type="text"> > > <input name="isdn_invoice_lines.date_time" value="< 30/03/2007" > > type="text"> > > > > On submission the prototype Form.serialze is used to serialize before > > posting. > > > > Problem: > > > > When input types contain multiple values (multiple fields with the > > same name for instance) with special characters in them (like > or > > <) strange things start to happen. > > > > When the input is single value with special characters all is fine. > > > > Example serialized output: > > > > isdn_invoice_lines.date=%3C%2001%2F03%2F2007& > > isdn_invoice_lines.date_time=%253C%252001%252F03%252F2007& > > isdn_invoice_lines.date_time=%253C%252001%252F03%252F2007 > > > > I put in some linebreak for readabillity, this string is (ofcourse) > > one. > > > > The first field is encoded correctly. The other two fields have an > > extra ''25'' is added inside each encoded character, with the result > > that the server does not recognise it as url encoded and leaves it > > untouched. Further processing obviously results in various problems. > > > > My question now is if anyone bumped into this problem before and/or > > has found a solution for it. > > > > Thnx in advance. > > > > Regards, > > > > Martijn Teigeler > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 5, 5:38 pm, Matt Foster <mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Benjamin/Martijin Teigeler, > > I think your problem lies within having ampersands within the > values, as this character is the delimiter from one key value pair and > the next its going to always have huge problems in a query string. > Try switching that to something else and I think you''ll have much > better luck with data transmission.Hi, got the same problem here, even with just %20 (single space) which is absolutely needed. Any solution yet? Thx --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Viral.Korruption-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-14 16:00 UTC
Re: Prototype Form.serialize incorrect url encoding
This is caused by having elements with the same name. For example: <input name="myvar" value="Hello World"> <input name="myvar" value=""> After serialization you''d get something like this... ?myvar=Hello%2520World Why? 1st run it encodes, myvar = urlencode(Hello World) // myvar= Hello %20World 2nd run it encodes, myvar = urlencode(Hello%20World) // myvar= Hello %2520World Solution: Don''t use the same name/id ever. Also, never use the same name or id, They both must be unique from each other, Thanks IE. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---