• 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: Applescript in the future
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applescript in the future


  • Subject: Re: Applescript in the future
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 22 May 2013 20:19:45 -0700

On May 22, 2013, at 6:43 PM, Shane Stanley <email@hidden> wrote:

> On 23/05/2013, at 10:43 AM, Alex Zavatone <email@hidden> wrote:
>
>> Are the docs for that in the NSURL reference class, the file system programming guide or where?
>
> I can't remember where I read it, but I think it was something Chris Nebel said. But...
>
> The dictionary (wrongly) says it requires an alias. This is a mistake in the scripting dictionary template; it should say 'file'. (This mistake has been around in app dictionaries forever...) But when you pass a path, Cocoa scripting can turn it into a file, so you can often get away with passing a path.
>
> The problem is that you can't tell a sandboxed app to make a file from any old path. But if you pass it a file, which is just a wrapped NSURL, it accepts it the same as if the user picked it in an open panel.
>
> The bottom line: use files or aliases rather than paths when scripting sand-boxed apps.

I see Shane beat me to the explanation.  Yes, this is the one caveat to scripting a sandboxed application: if you're going to pass it files as parameters, you have to use a file object specifier (file/alias/POSIX file "blah"), and not a bare text path ("blah").

The reason has to do with sandbox extensions -- a sandboxed application cannot access files outside its container (modulo any entitlements), but the system can hand it "sandbox extensions" to particular files and folders, such as by the user picking something from an Open panel, which will allow the app to access that file or folder.  Apple Event Manager will add sandbox extensions for file references in event parameters, but will only do it for types that are unambiguously files, which includes file object specifiers, but *not* strings.


--Chris Nebel
AppleScript Engineering
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Applescript in the future (From: Chris Swain <email@hidden>)
 >Re: Applescript in the future (From: Alex Zavatone <email@hidden>)
 >Re: Applescript in the future (From: Shane Stanley <email@hidden>)
 >Re: Applescript in the future (From: Christopher Nebel <email@hidden>)
 >Re: Applescript in the future (From: Alex Zavatone <email@hidden>)
 >Re: Applescript in the future (From: Christopher Nebel <email@hidden>)
 >Re: Applescript in the future (From: Alex Zavatone <email@hidden>)
 >Re: Applescript in the future (From: Alex Zavatone <email@hidden>)
 >Re: Applescript in the future (From: Shane Stanley <email@hidden>)
 >Re: Applescript in the future (From: Alex Zavatone <email@hidden>)
 >Re: Applescript in the future (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: The latest AS date and AS Editor bugs
  • Next by Date: Re: Applescript in the future
  • Previous by thread: Re: Applescript in the future
  • Next by thread: Re: Applescript in the future
  • Index(es):
    • Date
    • Thread