• 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: NSString, stringByAppendingPathComponent, and Canonicalization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString, stringByAppendingPathComponent, and Canonicalization


  • Subject: Re: NSString, stringByAppendingPathComponent, and Canonicalization
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 04 Apr 2011 22:22:39 -0500

On Apr 4, 2011, at 10:08 PM, Jeffrey Walton wrote:

> I need to accept a filename from the user. Given the user supplied
> filename, I form a fully qualified name:
>
> NSString* pathName = [NSHomeDirectory(),
> stringByAppendingPathComponent:@"Documents"];
> NSString* fullPathName = [pathName  stringByAppendingPathComponent:filename];
>
> How do I canonicalize the the resulting fullPathName to verify there
> was no directory traversal goodness in the filename?

NSString* fullPathName = [pathName  stringByAppendingPathComponent:[filename lastPathComponent]];

Cheers,
Ken

_______________________________________________

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

References: 
 >NSString, stringByAppendingPathComponent, and Canonicalization (From: Jeffrey Walton <email@hidden>)

  • Prev by Date: Re: NSString, stringByAppendingPathComponent, and Canonicalization
  • Next by Date: Re: Programming Context Menu
  • Previous by thread: Re: NSString, stringByAppendingPathComponent, and Canonicalization
  • Next by thread: Re: NSString, stringByAppendingPathComponent, and Canonicalization
  • Index(es):
    • Date
    • Thread