johnbintz/rack-livereload — pull request #61 by nathanhoel (2014-12-08 18:49:41+00:00)
Title: Inject js code only into valid html head tags

This addresses issue #60

I think the idea was that https://github.com/johnbintz/rack-livereload/blob/master/lib/rack/livereload/body_processor.rb#L73 would prevent this issue from occurring.
However Rack can pass the entire document as a single line. So when entering this section of code the @livereload_added would still be false and then it would proceed to replace all occurrences of the text `

` with the injected code.

This version using proper XML parsing to find the `

` element.