discourse/discourse — pull request #1195 by kalleth (2013-07-15 10:24:40+00:00)
Title: Post analyser backtrace fix

When you create a post containing the following text:

trussell@myserver:~$ ping6 www.google.com
PING www.google.com(lb-in-x93.1e100.net) 56 data bytes
64 bytes from lb-in-x93.1e100.net: icmp_seq=1 ttl=54 time=42.2 ms
64 bytes from lb-in-x93.1e100.net: icmp_seq=2 ttl=54 time=41.7 ms

PostAnalyzer#linked_hosts will backtrace, because URI.parse is attempting to parse 'www.google.com(lb-in-x93.1e100.net)' (note lack of space between URI and open bracket).

This can be trivially 'fixed' by adding a begin/rescue block, however, I think the problem lies further down, in that raw_links/cooked_document should not return it as a link in the first place, or should return the initial www.x.com component only.

The test provided in this PR will cause the error to occur if the 'rescue' block is removed.