Skip to content

Fix HTML Previews#30

Merged
JensRavens merged 1 commit into
masterfrom
feature/html_preview
Jun 30, 2025
Merged

Fix HTML Previews#30
JensRavens merged 1 commit into
masterfrom
feature/html_preview

Conversation

@JensRavens

Copy link
Copy Markdown
Member

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.

@JensRavens
JensRavens requested review from Maxi211 and Copilot June 30, 2025 12:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.read as HTML-safe in the html method.
  • 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_safe is 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_safe can 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 Maxi211 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@JensRavens
JensRavens merged commit 5785814 into master Jun 30, 2025
1 check passed
@JensRavens
JensRavens deleted the feature/html_preview branch June 30, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants