Fix HTML Previews#30
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the HTML rendering method so that content served through the rendering engine is marked as safe for HTML output, enabling printer previews to display rendered documents instead of raw markup.
- Marks the result of
file.readas HTML-safe in thehtmlmethod. - Fixes printer preview display by allowing the view to render HTML rather than escape it.
Comments suppressed due to low confidence (3)
lib/pixelpress/document.rb:12
- [nitpick] Consider adding a method comment to explain why
html_safeis applied and under what conditions the input is guaranteed safe to prevent future confusion.
file.read.html_safe
lib/pixelpress/document.rb:12
- [nitpick] Add or update tests to verify that printer previews render HTML correctly and that no raw markup appears after this change.
file.read.html_safe
lib/pixelpress/document.rb:12
- Marking content as
html_safecan introduce XSS risks if the source isn’t guaranteed safe. Ensure that all inputs undergo proper escaping earlier in the rendering pipeline or document this assumption clearly.
file.read.html_safe
Maxi211
approved these changes
Jun 30, 2025
Maxi211
left a comment
There was a problem hiding this comment.
This is the first time I cloned the repo to that a look at it :)
Its pretty concise and the change seems reasonable to me.
We should update the readme at some point, since defaulting to html_safe is a bit unusual in the rails world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Documents that went through the rendering engine are html safe already (as the content was intentionally escaped/not escaped in the controller when generating the html), therefore the result can be marked as html safe. This allows printer previews to work out of the box and fix the issue that html is displayed instead of the rendered document.