• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking whether a file is a genuine PDF file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking whether a file is a genuine PDF file


  • Subject: Re: Checking whether a file is a genuine PDF file
  • From: James Walker <email@hidden>
  • Date: Mon, 05 Oct 2009 19:02:54 -0700

Graham Cox wrote:

On 04/10/2009, at 11:07 PM, Squ Aire wrote:

But that isn't good enough really, because a file can have the pdf extension without being a true PDF file.


This is true, but how far are you prepared to go? Others have suggested checking a few bytes into the file's header which should be reasonable enough, but I could create a file having a valid PDF header and garbage thereafter... you cannot protect yourself against that sort of thing, so the question is where your code would draw the line. Most people would draw it with a simple check of the extension and maybe for files that traditionally have been subject to extension abuse (I don't think pdf is one of them), a few header bytes.

What is it you're afraid of?

FWIW, in the classic Mac OS, it was not uncommon to see a PDF with NO extension, but with the file type set to 'PDF '.
--
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Checking whether a file is a genuine PDF file
      • From: Charles Srstka <email@hidden>
References: 
 >Checking whether a file is a genuine PDF file (From: Squ Aire <email@hidden>)
 >Re: Checking whether a file is a genuine PDF file (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: re: CoreData async fetch request
  • Next by Date: Re: Checking whether a file is a genuine PDF file
  • Previous by thread: Re: Checking whether a file is a genuine PDF file
  • Next by thread: Re: Checking whether a file is a genuine PDF file
  • Index(es):
    • Date
    • Thread