alexdunae/premailer — pull request #123 by GAV1N (2012-06-08 18:44:34+00:00)
Title: Fix regex that causes Premailer to identify HTML as URI

I came across a bug where Premailer identifies HTML content as a URI if the content includes a line that looks like a URI (i.e. a newline character followed by http://foobar.baz, https://foobar.baz, or ftp://foobar.baz). My HTML looked something like this:

```html

Premailer identified this HTML as a URI because of the following line:
http://foobar.com

```

This raised an exception when Premailer tried to parse the HTML content as a URI.

The problem had to do with using the ^ character in some of the regular expressions to match the beginning of a line. Using this character would match something that looked like a URI as long as it's either at the beginning of the content (which is desired) or preceded by a new line character (which is not desired, because a URI should just be one line and anything else is probably HTML content).

My fix simply changes the ^ regular expression character to the \A (beginning of string) character in some of the match tests of lib/premailer.rb. I also added a passing test spec that fails with the original code.