senny / sablon

Ruby Document Template Processor based on docx templates and Mail Merge fields.
MIT License
443 stars 126 forks source link

Check if media file being added to document has an extension #98

Closed stadelmanma closed 6 years ago

stadelmanma commented 6 years ago

As far as I know MS word requires an extension to be provided for any files in the media folder in order to set the content type. Previously an image without an extension would be allowed which would cause a corrupted document. This now raises an argument error. In theory I could check for an extension during context transformation and raise a ContextError instead but this was simpler and having this present in the #add_media method means it will work for any media added and not just images incase an end user extends Sablon's content types.