-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #374 from autolab/hotfix_tiny_fixes
Small Fixes
- Loading branch information
Showing
4 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module PDF | ||
def self.is_pdf?(file) | ||
return false unless file | ||
# all PDFs have '%PDF-<major-version>.<minor-version>' in them somewhere. | ||
# this is used instead of MIME type detection because it should work | ||
# for PDFs inside of Archives as well. | ||
# the scrub call prevents invalid byte sequence errors. | ||
return (file.scrub("*") =~ /\%PDF-\d+\.?\d+/) | ||
end | ||
end |