manalang
2008-Nov-11 03:58 UTC
auto_link failing on URLs with square brackets in query params
Patch included in the ticket. http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1353-auto_link-helper-fails-to-parse-some-urls-with-brackets Rich --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-11 10:28 UTC
Re: auto_link failing on URLs with square brackets in query params
On 11 Nov 2008, at 03:58, manalang wrote:> > Patch included in the ticket. > > http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1353-auto_link-helper-fails-to-parse-some-urls-with-bracketsSomething sensible needs to be done to auto_link_urls. It''s a hideous regular expression which no one can hope to read, hacked around over the years to add characters here and there but there''s always something it doesn''t handle. Could we not rewrite this from scratch starting from the grammar given in the RFC on urls (or some other more complete solution than lobbing a character in here or there)? Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-Nov-11 13:48 UTC
Re: auto_link failing on URLs with square brackets in query params
> Something sensible needs to be done to auto_link_urls. It''s a hideous > regular expression which no one can hope to read, hacked around over > the years to add characters here and there but there''s always > something it doesn''t handle. Could we not rewrite this from scratch > starting from the grammar given in the RFC on urls (or some other more > complete solution than lobbing a character in here or there)?Indeed I think it''s about time to consider rejigging how all that code functions. Perhaps it''s worth looking into adopting addressable or something similar? The URI library from stdlib has some nastiness with it''s parsing and matching code. Care to take a look into it? -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-11 14:00 UTC
Re: auto_link failing on URLs with square brackets in query params
On 11 Nov 2008, at 13:48, Michael Koziarski wrote:> >> Something sensible needs to be done to auto_link_urls. It''s a hideous >> regular expression which no one can hope to read, hacked around over >> the years to add characters here and there but there''s always >> something it doesn''t handle. Could we not rewrite this from scratch >> starting from the grammar given in the RFC on urls (or some other >> more >> complete solution than lobbing a character in here or there)? > > Indeed I think it''s about time to consider rejigging how all that code > functions. Perhaps it''s worth looking into adopting addressable or > something similar? The URI library from stdlib has some nastiness > with it''s parsing and matching code. > > Care to take a look into it? >Don''t see why not. I''ll see what approaches I can dig up. Fred> > -- > Cheers > > Koz > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Mislav Marohnić
2008-Nov-11 18:28 UTC
Re: auto_link failing on URLs with square brackets in query params
On Tue, Nov 11, 2008 at 11:28, Frederick Cheung <frederick.cheung@gmail.com>wrote:> > Could we not rewrite this from scratch > starting from the grammar given in the RFC on urls (or some other more > complete solution than lobbing a character in here or there)?The problem is that URLs allow much more characters that people actually want to be autolinked with the URL. Common pitfall is the regexp capturing the punctuation after the URL in a sentence. It''s all been nicely described on Coding Horror recently: http://www.codinghorror.com/blog/archives/001181.html And more recently, there are URLs -- even domain names -- that include Unicode characters, not that browser support for it is on the rise. I''d say: let''s autolink everything that starts with "https?://" or "www." up to the first whitespace or punctuation character before the whitespace *if* that character isn''t a closing parenthesis or bracket that has a matching one on the beginning. Whitelisting characters will always leave someone out, I''m afraid ... But my solution is just a quick thought, there may be tons of cases where it wouldn''t be appropriate. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Mislav Marohnić
2008-Nov-11 18:29 UTC
Re: auto_link failing on URLs with square brackets in query params
On Tue, Nov 11, 2008 at 19:28, Mislav Marohnić <mislav.marohnic@gmail.com>wrote:> And more recently, there are URLs -- even domain names -- that include > Unicode characters, not that browser support for it is on the rise. >Typo. I meant to say "...now* that browser support for it is on the rise" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-11 20:48 UTC
Re: auto_link failing on URLs with square brackets in query params
On 11 Nov 2008, at 18:28, Mislav Marohnić wrote:> On Tue, Nov 11, 2008 at 11:28, Frederick Cheung <frederick.cheung@gmail.com > > wrote: > > Could we not rewrite this from scratch > starting from the grammar given in the RFC on urls (or some other more > complete solution than lobbing a character in here or there)? > > The problem is that URLs allow much more characters that people > actually want to be autolinked with the URL. Common pitfall is the > regexp capturing the punctuation after the URL in a sentence. > > It''s all been nicely described on Coding Horror recently: http://www.codinghorror.com/blog/archives/001181.html >That is indeed very timely!> And more recently, there are URLs -- even domain names -- that > include Unicode characters, not that browser support for it is on > the rise. > > I''d say: let''s autolink everything that starts with "https?://" or > "www." up to the first whitespace or punctuation character before > the whitespace *if* that character isn''t a closing parenthesis or > bracket that has a matching one on the beginning. > > Whitelisting characters will always leave someone out, I''m > afraid ... But my solution is just a quick thought, there may be > tons of cases where it wouldn''t be appropriate.I think it''s certainly in the right direction. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Mislav Marohnić
2008-Nov-13 21:55 UTC
Re: auto_link failing on URLs with square brackets in query params
On Tue, Nov 11, 2008 at 21:48, Frederick Cheung <frederick.cheung@gmail.com>wrote:> > > I''d say: let''s autolink everything that starts with "https?://" or > > "www." up to the first whitespace or punctuation character before > > the whitespace *if* that character isn''t a closing parenthesis or > > bracket that has a matching one on the beginning. > > I think it''s certainly in the right direction.Patched: http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1353-auto_link-helper-fails-to-parse-some-urls-with-brackets#ticket-1353-3 Previously hideous regexp becomes this: %r{( https?:// | www\. ) [^\s<]+}x Added feature: intelligent closing bracket handling. You are now able to write this: I''ve read an interesting article about sprites (link: http://en.wikipedia.org/wiki/Sprite_(computer_graphics)) All this in less code than before. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Trevor Turk
2008-Nov-15 05:53 UTC
Re: auto_link failing on URLs with square brackets in query params
On Nov 13, 3:55 pm, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> Previously hideous regexp becomes this: %r{( https?:// | www\. ) [^\s<]+}x > > Added feature: intelligent closing bracket handling. You are now able to > write this:Just as an FYI - this is awesome. People have always bitched at me about the auto-linking stuff in my apps, and this looks like it solves all their problems. Thank you! - Trevor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---