Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

WRT this topic What should I do about , I want to know how can OS X learn and save those information in the @ field. I'm not looking for a way to disable this feature, but for a code (or pseudocode, idea, whatever) regarding the implementation of this thing. Thank you in advance.

share|improve this question
up vote 6 down vote accepted

As Daniel mentioned, the browser can store the source URL (and also the referrer) of a downloaded file in the extended attribute

First Apple added this to Safari for Mac OS X 10.4, then it was added to Chrome/Chromium [Issue 22289], and there is an outstanding enhancement request to add it to Firefox [Bug 337051].

As for the actual code to implement this, check out the Chromium patch.

share|improve this answer
Nice history :-) However, when using Safari I don't see the referrer (or at least not in the new downloads I tried to see if I missed something). Maybe things are different when right-clicking and downloading, or when a downloads starts automatically? (For example, some browsers don't send the referrer when opening links in new windows either.) – Arjan Nov 25 '10 at 21:57
Ah, you're right, mdls does show it for downloads that start automatically. And Finder's Get Info shows that as a comma-separated list, which I failed to notice! – Arjan Nov 25 '10 at 22:01

After downloading any file, running xattr file will show you what the browser has stored in the extended attributes:

xattr mydownload.gz

Next, more details:

xattr -p mydownload.gz 

xattr -p mydownload.gz 
62 70 6C 69 73 74 30 30 A1 01 5F 10 24 68 74 74
70 3A 2F 2F 73 75 [and so on]

...or, in readable format:

mdls -name kMDItemWhereFroms mydownload.gz
kMDItemWhereFroms = (

You can set those (or any attribute you want) yourself too:

xattr -w some-name some-value mydownload.gz

The following works too, even though is has different results when running the above commands again:

xattr -w mydownload.gz

And for the attribute, according to understand:

Typically, the Quarantine data consists of a set of 4 semicolon-delimited values (a set of decimal digits of an unknown purpose - typically 0000, an 8 character opaque ID, the name of the application that created the Quarantined file, and the application's UTI (Uniform Type Identifier) prefixed with a pipe symbol)

For example, for two different files downloaded using Mozilla FireFox, this looks like: 0000;4b392bb2;Firefox;|org.mozilla.firefox 0000;4b38d820;Firefox;|org.mozilla.firefox

Using Automator's Folder Actions you could run such commands for new files in a specific folder, if that's what you after.

share|improve this answer

It's set by the application downloading the file. No magic download detection, just an attribute set on the downloaded file by the downloading application.

I just downloaded a zip file using wget, Google Chrome, Firefox and Safari, and, as expected, the wget download has no extended attributes, the browser downloads have, as they're aware of that feature. Interestingly, the Firefox download set quarantine, but forgot to set, the information where the downloaded file was originally located (its URL). Safari and Chrome set both, wget neither.

share|improve this answer

That information is stored in what are called "extended attributes". John Siracusa has an excellent article discussing extended attributes when they were first introduced, in OS X 10.4:

It appears there is no longer a man page for the 'xattr' command line tool, but 'xattr -h' should show basic help.

A POSIX/BSD-level API is available in /usr/include/sys/xattr.h which defines C functions such as getxattr(), setxattr(), removexattr(), listxattr(), and their FILE-based cousins. (These commands, unlike 'xattr(1)', do have man pages).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .