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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com