Ensure response_body is escaped in html_example template #148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit resolves an issue for HTML documents when the
response_body
includes HTML markup.For example, if
response_body = {"email":"[email protected]","name":"<h1>Order 1</h1>","paid":true}
the generated HTML page won't escape the HTML, and
<h1>Order 1</h1>
will be rendered as a Heading 1. This is so because the mustache template renders theresponse_body
using triple curly braces rather than double curly braces. Triple curly braces were introduced to pretty print the JSON. But this functionality was later removed, and I can't see why triple braces are still needed.(Note: this issue only affects Rails 3 but not Rails 4 apps. I'm not certain why, but I believe it has to do with the changes to JSON handling (see release notes). This patch should be a transparent change for Rails 4 apps.)