Andreas Franke
2008-Jan-16 18:47 UTC
is there something like addslashes and stripslashes in prototype
if i would save the content of a textarea into mysql i eventually have to mask things like ,"/\ and so on. in php there are the add- and stripslashes functions you could use. is there somthing compareable like this in the string object of prototype? if not, it would very nice to have, i think. function addslashes(str) { str=str.replace(/\''/g,''\\\''''); str=str.replace(/\"/g,''\\"''); str=str.replace(/\\/g,''\\\\''); str=str.replace(/\0/g,''\\0''); return str; } function stripslashes(str) { str=str.replace(/\\''/g,''\''''); str=str.replace(/\\"/g,''"''); str=str.replace(/\\\\/g,''\\''); str=str.replace(/\\0/g,''\0''); return str; } Andreas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Diodeus
2008-Jan-16 19:43 UTC
Re: is there something like addslashes and stripslashes in prototype
No, but Javascript does. On Jan 16, 1:47 pm, "Andreas Franke" <i...-8Zvurif+njuzQB+pC5nmwQ@public.gmane.org> wrote:> if i would save the content of a textarea into mysql i eventually have to > mask things like ,"/\ and so on. > > in php there are the add- and stripslashes functions you could use. > > is there somthing compareable like this in the string object of prototype? > if not, it would very nice to have, i think. > > function addslashes(str) { > str=str.replace(/\''/g,''\\\''''); > str=str.replace(/\"/g,''\\"''); > str=str.replace(/\\/g,''\\\\''); > str=str.replace(/\0/g,''\\0''); > return str;} > > function stripslashes(str) { > str=str.replace(/\\''/g,''\''''); > str=str.replace(/\\"/g,''"''); > str=str.replace(/\\\\/g,''\\''); > str=str.replace(/\\0/g,''\0''); > return str; > > } > > Andreas--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti
2008-Jan-17 01:41 UTC
Re: is there something like addslashes and stripslashes in prototype
Please, PLEASE, do that kind of things server-side. Escape everything you are going to send to the database in the server, with php or whatever language you are using. If you rely on client-side validation, your clients may disable javascript and inject all kind of nasty sql into your app. Best, -Nicolas On Jan 16, 2008 5:43 PM, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > No, but Javascript does. > > > On Jan 16, 1:47 pm, "Andreas Franke" <i...-8Zvurif+njuzQB+pC5nmwQ@public.gmane.org> wrote: > > if i would save the content of a textarea into mysql i eventually have to > > mask things like ,"/\ and so on. > > > > in php there are the add- and stripslashes functions you could use. > > > > is there somthing compareable like this in the string object of prototype? > > if not, it would very nice to have, i think. > > > > function addslashes(str) { > > str=str.replace(/\''/g,''\\\''''); > > str=str.replace(/\"/g,''\\"''); > > str=str.replace(/\\/g,''\\\\''); > > str=str.replace(/\0/g,''\\0''); > > return str;} > > > > function stripslashes(str) { > > str=str.replace(/\\''/g,''\''''); > > str=str.replace(/\\"/g,''"''); > > str=str.replace(/\\\\/g,''\\''); > > str=str.replace(/\\0/g,''\0''); > > return str; > > > > } > > > > Andreas > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andreas Franke
2008-Jan-17 07:12 UTC
AW: [Rails-spinoffs] Re: is there something like addslashes and stripslashes in prototype
Thanks.. ----------------------------------------------------------> -----Ursprüngliche Nachricht----- > Von: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails- > spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] Im Auftrag von Diodeus > Gesendet: Mittwoch, 16. Januar 2008 20:44 > An: Ruby on Rails: Spinoffs > Betreff: [Rails-spinoffs] Re: is there something like addslashes and > stripslashes in prototype > > > No, but Javascript does. > > On Jan 16, 1:47 pm, "Andreas Franke" <i...-8Zvurif+njuzQB+pC5nmwQ@public.gmane.org> wrote: > > if i would save the content of a textarea into mysql i eventually have > to > > mask things like ,"/\ and so on. > > > > in php there are the add- and stripslashes functions you could use. > > > > is there somthing compareable like this in the string object of > prototype? > > if not, it would very nice to have, i think. > > > > function addslashes(str) { > > str=str.replace(/\''/g,''\\\''''); > > str=str.replace(/\"/g,''\\"''); > > str=str.replace(/\\/g,''\\\\''); > > str=str.replace(/\0/g,''\\0''); > > return str;} > > > > function stripslashes(str) { > > str=str.replace(/\\''/g,''\''''); > > str=str.replace(/\\"/g,''"''); > > str=str.replace(/\\\\/g,''\\''); > > str=str.replace(/\\0/g,''\0''); > > return str; > > > > } > > > > Andreas >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---