Don't use the ActiveSupport::SafeBuffer when using erb and Sinatra as middleware. Fixes #1256.

Add test case.
Add third-party apps support.
Merge pull request #1418 from namusyaka/fix-erb-of-sinatra

Escaped erb bug fix #1256