mileszs / wicked_pdf

PDF generator (from HTML) plugin for Ruby on Rails
http://www.mileszs.com/wicked-pdf-plugin
MIT License
3.52k stars 640 forks source link

Remote asset returning non-200 response does not trigger an error #1092

Open d4rky-pl opened 6 months ago

d4rky-pl commented 6 months ago

Issue description

When using wicked_pdf_stylesheet_link_tag, if the assets are precompiled or otherwise referenced via URL, WickedPDF tries to fetch the asset from remote URL using read_from_uri method in WickedPdf::WickedPdfHelper::Assets. This method calls Net::HTTP.get(URI(uri)) which does not fail if the status code is different than 200, resulting in a broken PDF if either the server responding to the request (for ex. 502 error) or the asset (404) is unavailable without ever informing the user.

Expected or desired behavior

If the remote asset is not available, WickedPDF should throw an exception. This could be configurable to avoid breaking change.

System specifications

wicked_pdf gem version: 2.6.3