Opening files with com.apple.quarantine flag results in incorrect app activation

Originator:rsesek
Number:rdar://8019954 Date Originated:24-May-2010 12:06 PM
Status:Duplicate/8089263 Resolved:17-Jun-2010 07:30 PM
Product:Mac OS X Product Version:10.6.3 10D2063a
Classification:UI/Usability Reproducible:Always
 
Summary:
Applications that try to open files using -[NSWorkspace openFile:] and variants will remain active if the file being open has a com.apple.quarantine extended attribute. We see this in both Safari and Chrome when the user downloads a file (a PDF, for example) and then tries to open it from within the browser by clicking on the file's icon in the downloads window/shelf. If Preview is not running, it will then open the file as expected, but the original application (the browser) will remain the active application. When the quarantine flag is not set and the above process is repeated, Preview will become the active application, as it should.

Steps to Reproduce:
1. Make sure Preview is NOT running.
2. Go to www.irs.gov and Option-Click the "Form 941" link to download the file.
3. After it has been downloaded, double-click the file in the Downloads window.
4. Preview will open the file, but Safari will remain the active application.
5. Quit Preview.
6. Option-Click the "Form W-9" link.
7. In Terminal, type "xattr -d com.apple.quarantine ~/Downloads/fw9.pdf" to clear the quarantine bit.
8. Double-click the file in Safari's downloads window.
9. Preview opens the file and is the active application.

Alternatively, you can use the reduced test case application attached. It will copy (with extended attrs) a test.pdf file (downloaded with Chrome) that has the quarantine flag. Be sure to quit Preview and rebuild in between uses of the test app (so that the file is recopied with its extended attribute each time). There are two buttons: one that will open the file normally via -[NSWorkspace openFile:withApplication:andDeactivate], and one that uses removexattr() to programmatically clear the quarantine bit before opening the file.

Expected Results:
In step (4), Preview should become the active application, regardless of the quarantine flag.

Actual Results:
As mentioned in step (4), the original application (Safari or Chrome) keeps its active state, rather than deactivating.

Regression:
May also happen on 10.5.

Notes:
We are tracking this as a Chrome bug at http://code.google.com/p/chromium/issues/detail?id=32921.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!