Sebastian von Conrad
2006-Apr-11 23:13 UTC
[Rails] Firefox won''t let me send ''&'' with AJAX!
Hi everyone, I''ve encountered a HUGE problem, which may not be RoR-oriented, but there might be a workaround somehow. See, at this moment, I''m unable to send AJAX requests back and forth when the information contains an ampersand (''&''). In essence, request is never completed. The odd thing is that it only happens with Firefox (IE and Opera works fine). This means that I''m unable to pass along html entities, since they all, conveniently enough, contains ampersands. I can''t replace the ampersand with the html entitiy for it, either, since that would also contain an ampersand. Being Swedish, I''m kinda screwed if I can''t use å, ä and ö on my website. Replacing them with the letter without using entities is out of the question, too; they only come out as nice boxes if I do. :) Please note that the request itself can be without ampersands, and it still doesn''t work as long as the data I fetch contains one or more ampersands. Does anyone have a clue on how to fix this, or work around it? I''ve tried creating a function which substitutes certain characters with their entity-form using string.gsub(), but that doesn''t work either. Is there a way to perform such a substitution after the AJAX-request is completed, and if so, how do I do that? Thanks in advance, Sebastian -- Posted via http://www.ruby-forum.com/.
Manuel Holtgrewe
2006-Apr-11 23:15 UTC
[Rails] Firefox won''t let me send ''&'' with AJAX!
Hi, Sebastian. Could you give us "the simplest thing that works", i.e. the "simplest thing that breaks" in your case? It will be hard to find someone who has the same problem when you describe it abstractly but very easy if you give an example :) Regards, Manuel
Mark Van Holstyn
2006-Apr-11 23:18 UTC
[Rails] Firefox won''t let me send ''&'' with AJAX!
I''m sure there is a helper within RoR that will do this for you, but you need to escape certain characters in urls. See http://www.december.com/html/spec/esccodes.html for what the escape sequences are (for example, "&" is "%26" --mark On 4/11/06, Sebastian von Conrad <sebastian@march4.se> wrote:> > Hi everyone, > > I''ve encountered a HUGE problem, which may not be RoR-oriented, but > there might be a workaround somehow. > > See, at this moment, I''m unable to send AJAX requests back and forth > when the information contains an ampersand (''&''). In essence, request is > never completed. The odd thing is that it only happens with Firefox (IE > and Opera works fine). > > This means that I''m unable to pass along html entities, since they all, > conveniently enough, contains ampersands. I can''t replace the ampersand > with the html entitiy for it, either, since that would also contain an > ampersand. Being Swedish, I''m kinda screwed if I can''t use å, > ä and ö on my website. Replacing them with the letter without > using entities is out of the question, too; they only come out as nice > boxes if I do. :) > > Please note that the request itself can be without ampersands, and it > still doesn''t work as long as the data I fetch contains one or more > ampersands. > > Does anyone have a clue on how to fix this, or work around it? I''ve > tried creating a function which substitutes certain characters with > their entity-form using string.gsub(), but that doesn''t work either. Is > there a way to perform such a substitution after the AJAX-request is > completed, and if so, how do I do that? > > Thanks in advance, > > Sebastian > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060411/c79953f4/attachment-0001.html
Sebastian von Conrad
2006-Apr-11 23:46 UTC
[Rails] Re: Firefox won''t let me send ''&'' with AJAX!
Manuel Holtgrewe wrote:> Could you give us "the simplest thing that works", i.e. the "simplest > thing that breaks" in your case? It will be hard to find someone who > has the same problem when you describe it abstractly but very easy if > you give an example :)Manuel, I''m not really sure how to give an example of it; I''ve used link_to_remote to fetch information from a database - nothing strange or alien. Controller: @staff = Staff.find(:first, :conditions => [ "name = ?", params[:name]]) render :partial => "staff" However, as *soon* as the information in any way contains an ampersand, it ceases to function. For example, if my partial looks like this: <%= @staff.name %> <%= @staff.position %> <%= @staff.email %> ..it will work without a problem for certain entries (ex. @staff.name == Foo Bar), but others will fail (ex. @staff.name == Foo Bará), only because that specific database column contained an ampersand. Omitting <%= @staff.name %> from the partial makes it work again, though. Again, only in Firefox. It works with ampersands in IE and Opera. Mark Van Holstyn wrote:> I''m sure there is a helper within RoR that will do this for you, but you > need to escape certain characters in urls. See > http://www.december.com/html/spec/esccodes.html for what the escape > sequences are (for example, "&" is "%26"Mark, the problem does not appear to be in the urls, but rather the data fetched from the database, so I''m not sure if escaping certain characters in url would work. Best regards, Sebastian -- Posted via http://www.ruby-forum.com/.
Mark Van Holstyn
2006-Apr-12 00:37 UTC
[Rails] Re: Firefox won''t let me send ''&'' with AJAX!
If you are sending "&" in the url as data, you will have problems because "&" is what url''s use to split fields. If you aren''t sending "&" in the url, them I am not sure what the porblems you are having is, in which case I would agree with Manuel, I think we need an example. --mark -- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/39a87edc/attachment.html
subimage interactive
2006-Apr-12 01:05 UTC
[Rails] Re: Firefox won''t let me send ''&'' with AJAX!
So use POST instead of GET... problem solved. On 4/11/06, Mark Van Holstyn <mvette13@gmail.com> wrote:> > If you are sending "&" in the url as data, you will have problems because > "&" is what url''s use to split fields. If you aren''t sending "&" in the url, > them I am not sure what the porblems you are having is, in which case I > would agree with Manuel, I think we need an example. > > --mark > > > -- > Mark Van Holstyn > mvette13@gmail.com > http://lotswholetime.com > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- seth at subimage interactive http://www.subimage.com/sublog/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/f58d0918/attachment-0001.html
Sebastian von Conrad
2006-Apr-12 15:05 UTC
[Rails] Re: Re: Firefox won''t let me send ''&'' with AJAX!
Mark Van Holstyn wrote:> If you are sending "&" in the url as data, you will have problems > because > "&" is what url''s use to split fields. If you aren''t sending "&" in the > url, > them I am not sure what the porblems you are having is, in which case I > would agree with Manuel, I think we need an example. > > --markOkay, full example: # template # <%= link_to_remote("Technology used", :update => ''m4-right-wrap-projdesc'', :url => { :action => :projtech, :id => @project.id }, :loading => "Element.hide(''m4-right-wrap-projdesc'')", :complete => { visual_effect(:appear, ''m4-right-wrap-projdesc''), visual_effect(:appear, ''m4-right-proj-glossary'')}) %> # template render for id #1 # <a href="#" onclick="new Ajax.Updater(''m4-right-wrap-projdesc'', ''/portfolio/projtech/1'', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Appear(''m4-right-wrap-projdesc'',{});new Effect.Appear(''m4-right-proj-glossary'',{});}, onLoading:function(request){Element.hide(''m4-right-wrap-projdesc'')}}); return false;">Technology used</a> # controller # def projtech @project = Project.find(params[:id]) render :partial => "tech" end # partial # <%= @project.technology %> # end # This doesn''t work because in my MySQL table called "projects", the column "technology" for id #1 contains an ampersand. As you can see, I don''t have & in the url, which suggests that that''s not the problem. So, basically, this doesn''t work in Firefox because the data I''m *fetching* in the MySQL table contains an ampersand (or more). It has nothing to do with the url. Try it yourselves - it won''t work in Firefox 1.5. I also tried adding :method => ''post'' to the link_to_remote, but that didn''t change anything. Regards, Sebastian -- Posted via http://www.ruby-forum.com/.
Sebastian von Conrad
2006-Apr-12 15:14 UTC
[Rails] Re: Re: Firefox won''t let me send ''&'' with AJAX!
On second thought, let''s make the example even easier: Create a link_to_remote; call it whatever you wish and update whichever id of your choice. Create an action to call, call that one whatever you wish. In the action you call, simply have: def action_to_be_called_by_ajax render_text "ä" end ...and it won''t work in Firefox. Remove the ampersand in the text to be rendered and it will. - Sebastian -- Posted via http://www.ruby-forum.com/.
Mark Van Holstyn
2006-Apr-12 16:02 UTC
[Rails] Re: Re: Firefox won''t let me send ''&'' with AJAX!
Your last example works for me and displays... ? The only thing i can think of is if your firefox cannot display non-acsii characters, however my firefox definately works. --mark On 4/12/06, Sebastian von Conrad <sebastian@march4.se> wrote:> > On second thought, let''s make the example even easier: > > Create a link_to_remote; call it whatever you wish and update whichever > id of your choice. Create an action to call, call that one whatever you > wish. In the action you call, simply have: > > def action_to_be_called_by_ajax > render_text "ä" > end > > ...and it won''t work in Firefox. Remove the ampersand in the text to be > rendered and it will. > > - Sebastian > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/7bb89b6d/attachment.html
D. Taylor Singletary
2006-Apr-12 16:03 UTC
[Rails] Re: Re: Firefox won''t let me send ''&'' with AJAX!
Don''t forget that Rails has the h(string) helper method availabile in your view. So when you want to show one of your problematic data pieces in a view you''d do this <%= h("This & That") %> This might solve your problem. On 4/12/06, Sebastian von Conrad <sebastian@march4.se> wrote:> > On second thought, let''s make the example even easier: > > Create a link_to_remote; call it whatever you wish and update whichever > id of your choice. Create an action to call, call that one whatever you > wish. In the action you call, simply have: > > def action_to_be_called_by_ajax > render_text "ä" > end > > ...and it won''t work in Firefox. Remove the ampersand in the text to be > rendered and it will. > > - Sebastian > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/0c87078a/attachment.html
Sebastian von Conrad
2006-Apr-12 17:03 UTC
[Rails] Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Mark Van Holstyn wrote:> Your last example works for me and displays... > ? > > The only thing i can think of is if your firefox cannot display > non-acsii > characters, however my firefox definately works. > > --markThat''s very strange, since it doesn''t work for me, or for several people I''ve asked. Maybe you''re using another version of Firefox? I have 1.5.0.1. - Sebastian -- Posted via http://www.ruby-forum.com/.
Sebastian von Conrad
2006-Apr-12 17:09 UTC
[Rails] Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
D. Taylor Singletary wrote:> Don''t forget that Rails has the h(string) helper method availabile in > your > view. > > So when you want to show one of your problematic data pieces in a view > you''d > do this > > <%= h("This & That") %> > > This might solve your problem.This is useful, but unfortunately didn''t solve this problem. Now the data is displayed and everything, but as the entity (ä) instead of the symbol it represents. Another strange thing I''ve noticed is that &auml; works (in other words when I substitute & for &). That also outputs ä instead of the symbol, though, but I''m currently investigating a method of working around the problem. - Sebastian -- Posted via http://www.ruby-forum.com/.
Sebastian von Conrad
2006-Apr-12 18:28 UTC
[Rails] Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Sorry to bump this, but it seems that the method I was trying out didn''t work. Basically, if someone could figure out some client-side way to replace characters (& with & in this case), I''d be eternally grateful. Rails-code won''t work, since that''s server-side. JavaScript doesn''t appear to work, either, at least not the way I tried (writing a function and calling it from the partial). Can it be done with RJS, somehow? I was for a split-second thinking that replace_html could help, but then I realised that''s only for id''s and doesn''t work as a global find/replace. Besides, that''s server-side, as well. I also tried printing the symbols directly and forcing a special encoding, but that wasn''t reliable at all... Again, I''m very, very thankful for any help on the topic. This is literally the last thing left to do on a major site for me, and I''m already past the deadline. Regards, Sebastian -- Posted via http://www.ruby-forum.com/.
Douglas Livingstone
2006-Apr-12 20:03 UTC
[Rails] Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
2006/4/12, Sebastian von Conrad <sebastian@march4.se>:> > Again, I''m very, very thankful for any help on the topic. This is > literally the last thing left to do on a major site for me, and I''m > already past the deadline. >If you replace the link_to_remote with a link_to, does it display properly? (IOW: Is it only realted to XMLHttpRequest? Can you pass you data through XMLHttpRequest or is it a prototype problem?) Douglas
Mark Van Holstyn
2006-Apr-12 21:17 UTC
[Rails] Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
I am running Firefox 1.5.0.1 as well. If you do something like this... def action_to_be_called_by_ajax render_text "here is the character: ä :there was the character" end What is displayed? anything? "here is the character: :there was the character"? --mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/10086d73/attachment.html
Sebastian von Conrad
2006-Apr-12 22:15 UTC
[Rails] Re: Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Douglas Livingstone wrote:> If you replace the link_to_remote with a link_to, does it display > properly? (IOW: Is it only realted to XMLHttpRequest? Can you pass you > data through XMLHttpRequest or is it a prototype problem?) > > DouglasIt''s only related to XMLHttpRequest; link_to works fine. Mark Van Holstyn wrote:> I am running Firefox 1.5.0.1 as well. If you do something like this... > > def action_to_be_called_by_ajax > render_text "here is the character: ä :there was the character" > end > > What is displayed? anything? "here is the character: :there was the > character"? > > --markNothing at all happens. Or, well, the request is processed but never finished. In other words, everything I specify under :loading is executed, but :complete never is. Regards, Sebastian -- Posted via http://www.ruby-forum.com/.
Kenneth Lee
2006-Apr-12 22:43 UTC
[Rails] Re: Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Silly question but is ä considered a legal entity in XML ? On 4/12/06, Sebastian von Conrad <sebastian@march4.se> wrote:> Douglas Livingstone wrote: > > If you replace the link_to_remote with a link_to, does it display > > properly? (IOW: Is it only realted to XMLHttpRequest? Can you pass you > > data through XMLHttpRequest or is it a prototype problem?) > > > > Douglas > > It''s only related to XMLHttpRequest; link_to works fine. > > Mark Van Holstyn wrote: > > I am running Firefox 1.5.0.1 as well. If you do something like this... > > > > def action_to_be_called_by_ajax > > render_text "here is the character: ä :there was the character" > > end > > > > What is displayed? anything? "here is the character: :there was the > > character"? > > > > --mark > > Nothing at all happens. Or, well, the request is processed but never > finished. In other words, everything I specify under :loading is > executed, but :complete never is. > > Regards, > > Sebastian > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Sebastian von Conrad
2006-Apr-12 23:27 UTC
[Rails] Re: Re: Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Kenneth Lee wrote:> Silly question but is ä considered a legal entity in XML ?That''s is such a ridiculous cause of a problem. Wow, do I feel stupid, or what? 24 hours of cry and dispair, and it never even occured to me once - not once - to try ä instead of ä. I''m getting blas? about this whole thing, I believe. Thanks, Kenneth. You spared me a lot of trouble and ridicule (though I think I have received/will receive plenty of both). - Sebastian -- Posted via http://www.ruby-forum.com/.
Conrad Taylor
2006-Apr-12 23:51 UTC
[Rails] Re: Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Hey Kenneth Lee, it appears to be a valid character if you''re using iso-88591 <http://www.w3.org/TR/REC-html40/sgml/entities.html#iso-88591> as your character encoding for your HTML file. By doing the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Some Stuff</title> </head> <body> ... </body> </html> Peace, -Conrad On 4/12/06, Kenneth Lee <klee@klmn.net> wrote:> > Silly question but is ä considered a legal entity in XML ? > > On 4/12/06, Sebastian von Conrad <sebastian@march4.se> wrote: > > Douglas Livingstone wrote: > > > If you replace the link_to_remote with a link_to, does it display > > > properly? (IOW: Is it only realted to XMLHttpRequest? Can you pass you > > > data through XMLHttpRequest or is it a prototype problem?) > > > > > > Douglas > > > > It''s only related to XMLHttpRequest; link_to works fine. > > > > Mark Van Holstyn wrote: > > > I am running Firefox 1.5.0.1 as well. If you do something like this... > > > > > > def action_to_be_called_by_ajax > > > render_text "here is the character: ä :there was the character" > > > end > > > > > > What is displayed? anything? "here is the character: :there was the > > > character"? > > > > > > --mark > > > > Nothing at all happens. Or, well, the request is processed but never > > finished. In other words, everything I specify under :loading is > > executed, but :complete never is. > > > > Regards, > > > > Sebastian > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/ca65f2a4/attachment.html
Conrad Taylor
2006-Apr-13 00:16 UTC
[Rails] Re: Re: Re: Re: Firefox won''t let me send ''&'' with AJAX!
Hi, I have used the following and it worked for both numberical and character: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Some Stuff</title> </head> <body> <h2>Using character entity: ä</h2> <h2>Using numerical entity: ä</h2> </body> </html> Peace, -Conrad On 4/12/06, Conrad Taylor <conradwt@gmail.com> wrote:> > Hey Kenneth Lee, it appears to be a valid character if you''re using > iso-88591 <http://www.w3.org/TR/REC-html40/sgml/entities.html#iso-88591>as your character encoding for your HTML file. By doing the following: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd > "> > <html xmlns="http://www.w3.org/1999/xhtml" > > > <head> > <meta http-equiv="Content-Type" > content="text/html; charset=ISO-8859-1" /> > <title>Some Stuff</title> > </head> > <body> > > > ... > > </body> > </html> > > Peace, > > -Conrad > > > On 4/12/06, Kenneth Lee <klee@klmn.net> wrote: > > > > Silly question but is ä considered a legal entity in XML ? > > > > On 4/12/06, Sebastian von Conrad <sebastian@march4.se> wrote: > > > Douglas Livingstone wrote: > > > > If you replace the link_to_remote with a link_to, does it display > > > > properly? (IOW: Is it only realted to XMLHttpRequest? Can you pass > > you > > > > data through XMLHttpRequest or is it a prototype problem?) > > > > > > > > Douglas > > > > > > It''s only related to XMLHttpRequest; link_to works fine. > > > > > > Mark Van Holstyn wrote: > > > > I am running Firefox 1.5.0.1 as well. If you do something like > > this... > > > > > > > > def action_to_be_called_by_ajax > > > > render_text "here is the character: ä :there was the > > character" > > > > end > > > > > > > > What is displayed? anything? "here is the character: :there was the > > > > > > character"? > > > > > > > > --mark > > > > > > Nothing at all happens. Or, well, the request is processed but never > > > finished. In other words, everything I specify under :loading is > > > executed, but :complete never is. > > > > > > Regards, > > > > > > Sebastian > > > > > > -- > > > Posted via http://www.ruby-forum.com/. > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060413/b517c290/attachment.html
Hi! I am writing to reply to the first post. I am Greek so html entities are crucial in web development for me too! I understand exactly what the problem is. When one tries to send html entities that contain the "&" (ampersand) the data part of the send() method of the XMLHttpRequest breaks, because this is the character that separates url fields from each other. To my mind the send method ought to have two ways of sending data! The one that it already has for GET methods and another one with an unspecified number of possible fields in case one wants to send a POST method. It is totally silly - I believe - to send a POST by saying: xml_http_request.send( "name=Takis&age=27" ); This is the classic way for doing this for a GET and there are good reasons for it, so why use it in a POST? I will never understand it! Now I cannot really understand how the other people here do this or the way they proposed - that seems to work for the original poster. Either I don''t get or I am too dizzy searching for a solution for quite some time now. So I thought of a plain solution. How are "&" sent in a GET usually? They are escaped! They are escaped by "%26"! So this is what I believe one should do when sending large texts - like the ones that online rich text editors (ie FCK, etc) produce - via an XMLHttpRequest send() POST! That is until the people that run the internet (lol) invent a new send() method for XMLHttpRequest like: xml_http_request.send( { name: "Takis", age: "27", last_words: "I want to send an & with AJAX!" } ); Bye... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
As a complement to my previous I should mention that one should generally the encodeURIComponent() function for escaping the content one wishes to send. So instead of esacping the "&" or anything like it one can simply escape the whole content like: content = encodeURIComponent( content ); Cheers! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> As a complement to my previous I should mention that one should > generally the encodeURIComponent() function for escaping the content one wishes to send. So instead of esacping the "&" or anything like it one can simply escape the whole content like: content = encodeURIComponent( content );just a quick note.. that''s done behind the scenes when you use Element.serialize (or Form.serialize) in prototype.js, and it''s the method that is automatically called when you use the rails remote methods defined in the helpers. the only thing you should be careful about is encodeURIComponent by design will always send the data in UTF-8, whatever the encoding of your original page was, so take it into account server side or you''ll end up with strange characters. regards, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, I''ve got the same problem when I use an ampersand in filenames, I just get an xml error message and nothing is working anymore. But I''ve also got another problem with parenthesis/brackets like "folder(2006)". I''m programming an online file_browser and I can''t enter directories by link_to_remote which have a name with brackets or even contain a file which is named with brackets. I always get an error message that says, that one ")" is missing. So is there any way to escape all special characters and signs for a whole document? Also the content-type handling doesn''t affect anything, neither self made escape-functions with h(), because in some cases I think I need an "รค" converted to ä in other cases to ä? Is that possible or am I just to blind to see the solution? Any help? Pleeeaaase =) Thanks in advance! Nina -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Nina, nina wrote:> But I''ve also got another problem with parenthesis/brackets > like "folder(2006)". I''m programming an online file_browser > and I can''t enter directories by link_to_remote which have a > name with brackets or even contain a file which is named with > brackets. I always get an error message that says, that one ")" > is missing.If you post some code that''s causing you problems, maybe we can help. As far as the problem above, link_to_remote invokes a controller method. At first blush, it doesn''t sound like you''re using it correctly, but code and an explanation of what you''re trying to accomplish will probably help. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I use the following snippet in a before_filter to clean up params affected by this encoding ''feature'': URI: /admin/en/products_extras?extra_id=1&product_id Filter snippet: def clean_params_proxy(*to_clean) to_clean.map{|p| params[p] = params["amp;#{p.to_s}"] if params.has_key?("amp;#{p.to_s}")} end Usage: class Admin::ProductExtrasController < Admin::BaseController before_filter :clean_params, :only => :create def create; end def destroy; end protected def clean_params clean_params_proxy :product_id, :extra_id end end - Lourens On 2007/04/13, at 14:01, Bill Walton wrote:> > Hi Nina, > > nina wrote: > >> But I''ve also got another problem with parenthesis/brackets >> like "folder(2006)". I''m programming an online file_browser >> and I can''t enter directories by link_to_remote which have a >> name with brackets or even contain a file which is named with >> brackets. I always get an error message that says, that one ")" >> is missing. > > If you post some code that''s causing you problems, maybe we can > help. As > far as the problem above, link_to_remote invokes a controller > method. At > first blush, it doesn''t sound like you''re using it correctly, but > code and > an explanation of what you''re trying to accomplish will probably help. > > Best regards, > Bill > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lourens Naude ha scritto:> I use the following snippet in a before_filter to clean up params > affected by this encoding ''feature'': > > URI: /admin/en/products_extras?extra_id=1&product_id > > Filter snippet: > > def clean_params_proxy(*to_clean) > to_clean.map{|p| params[p] = params["amp;#{p.to_s}"] if > params.has_key?("amp;#{p.to_s}")} > end > > Usage: > > class Admin::ProductExtrasController < Admin::BaseController > > before_filter :clean_params, :only => :create > > def create; end > > def destroy; end > > protected > > def clean_params > clean_params_proxy :product_id, :extra_id > end > > end > > - Lourens > > On 2007/04/13, at 14:01, Bill Walton wrote: > > >> Hi Nina, >> >> nina wrote: >> >> >>> But I''ve also got another problem with parenthesis/brackets >>> like "folder(2006)". I''m programming an online file_browser >>> and I can''t enter directories by link_to_remote which have a >>> name with brackets or even contain a file which is named with >>> brackets. I always get an error message that says, that one ")" >>> is missing. >>> >> If you post some code that''s causing you problems, maybe we can >> help. As >> far as the problem above, link_to_remote invokes a controller >> method. At >> first blush, it doesn''t sound like you''re using it correctly, but >> code and >> an explanation of what you''re trying to accomplish will probably help. >> >> Best regards, >> Bill >> >> >> >> >> > > > > > >I don''t understand what is the problem but I see a formal error amp; instead of & Correct this def clean_params_proxy(*to_clean) to_clean.map{|p| params[p] = params["amp;#{p.to_s}"] if params.has_key?("amp;#{p.to_s}")} end into def clean_params_proxy(*to_clean) to_clean.map{|p| params[p] = params["&#{p.to_s}"] if params.has_key?("&#{p.to_s}")} end Hope this help and have fun ! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---