I'm converting ActionText HTML into PDF using Prawn-Markup. I need large images to be scaled down (not resized or cropped), which requires setting the width in the style attribute, which Prawn-Markup then forwards to Prawn.
Unfortunately, the style attribute is removed by Rails' Sanitizer when rendering the template.
# app/views/active_storage/blobs/_blob.html.erb
image_tag blob, style: "width: #{blob.metadata[:whidth]}px"
# => "<img style=\"width: 200px\" src=\"...\" />
# app/views/action_text/content/_layout.html.erb
# => "<img src=\"...\" />
The style attribute needs to be preserved when rendering blobs, but I don't want to disable style sanitization for the entire app.
Any idea how to achieve that?
EDIT:
I was able to allow style
attributes in actiontext by adding it to the ActionText::Attachment::ATTRIBUTES
in an initializer, which works for blobs, but leaves actiontext open to abuse. Still searching…