mileszs / wicked_pdf

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

Do not register pdf mime type implicitly #453

Open aeden opened 9 years ago

aeden commented 9 years ago

Right now https://github.com/mileszs/wicked_pdf/blob/ed226801665747bdc8e6a14309f0109bcd196a6f/lib/wicked_pdf/railtie.rb#L40 registered the pdf extension. This means that when someone goes to a page and ends the URL in .pdf, it will result in a 500 error.

I humbly request that you make the registration of PDF a choice.

unixmonkey commented 9 years ago

I am able to reproduce the issue, but I don't see how it is better to not register the mime type.

If you go to a random URL and end it with .gif or .json you have the same issue, right?

There's a longstanding open issue on Rails for this that has some creative ways to prevent this from happening, but I think I'm with you that requesting a format you don't implement on each action shouldn't raise an ActionView::MissingTemplate error.

Are you not registering it in your app? How do you handle serving pdf's without it, as octet-stream downloads?

I'm open to suggestions or pull requests for the configuration initializer if you think that's the best route to take, but I would think it should be enabled by default.