I''m calling auto_link on a block of HTML-escaped text. It is failing to correctly link URLs that have multiple GET string variables. For example: http://www.google.com/search?hl=en&q=bugzilla&btnG=Google+Search ...is escaped to: http://www.google.com/search?hl=en&q=bugzilla&btnG=Google+Search ...which auto_link() links as: <a href="http://www.google.com/search?hl=en&" name="830_link" target="_blank">http://www.google.com/search?hl=en&</a>;q=bugzilla&btnG=Google+Search (here it is again w/o MY escaping since I''m not sure how this forum escapes values [PREVIEW OPTION IS NEEDED]) <a href="http://www.google.com/search?hl=en&" name="830_link" target="_blank">http://www.google.com/search?hl=en&</a>;q=bugzilla&btnG=Google+Search Has anyone run into this before? Short of not escaping HTML (which isn''t an option) what can be done to fix this? Thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
Caleb Jones wrote:> For example: > http://www.google.com/search?hl=en&q=bugzilla&btnG=Google+SearchWell, it looks like this forum is doing this correctly. Any ruby-forum.com dev''s out there that can explain how they are both escaping HTML and calling auto linking URLs? -- 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 -~----------~----~----~----~------~----~------~--~---
> Well, it looks like this forum is doing this correctly. Any > ruby-forum.com dev''s out there that can explain how they are both > escaping HTML and calling auto linking URLs? >I had the same problem. Here is a simplified version that worked for me:> def auto_link_urls (text) > url_regex = / > ([a-zA-Z][0-9a-zA-Z+\-\.]*:\/\/|www\.) > [0-9a-zA-Z;\/?:@&=+$\.\-_!~*''()%]+ > (\#[0-9a-zA-Z;\/?:@&=+$\.\-_!~*''()%]+)? > /x > > text.gsub(url_regex) do |link| > link = ''http://'' + link if $1 == ''www.'' > link_text = block_given? ? yield(link) : link > ''<a href="'' + link + ''">'' + link_text + ''</a>'' > end > endIt doesn''t detect already linked URLs (I didn''t need it) but it allows a wider range of URLs (ftp://..., for example) and works with HTMLized URLs (...?foo=1&bar=2...) and some other special case original version doesn''t seem to detect (http://www.example.com/?foo). -- Francesc Rosàs <francesc-hi6Y0CQ0nG0@public.gmane.org> http://strut.ath.cx/ r00z-/eSpBmjxGS4dnm+yROfE0A@public.gmane.org (IM) GPG ID: 0xFC84EFAB --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---