curl/docs/cmdline-opts/xattr.md
Viktor Szakats 6bff85be68
tool_xattr: add support for Windows alternate data stream
Requires a supported filesystem, i.e. NTFS.

Example:
```console
> curl.exe https://curl.se/index.html --output test.txt --xattr --referer https://curl.se/
> cat < test.txt:Zone.Identifier

[ZoneTransfer]
HostUrl=https://curl.se/index.html
ReferrerUrl=https://curl.se/
```

Where newlines are CLRF, `ReferrerUrl` is set when using `--referer`
option.

Also:
- test688: make it test `--referer`.
- document `user.xdg.referrer.url` in `--xattr` man page.

Refs:
https://en.wikipedia.org/wiki/Mark_of_the_Web
https://en.wikipedia.org/wiki/NTFS#Alternate_data_stream_(ADS)
https://learn.microsoft.com/en-us/windows/win32/fileio/file-streams
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c54dec26-1551-4d3a-a0ea-4fa40f848eb3

Ref: #22345

Closes #22354
2026-07-22 12:27:39 +02:00

30 lines
988 B
Markdown

---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Long: xattr
Help: Store metadata in extended file attributes
Category: output
Added: 7.21.3
Multi: boolean
See-also:
- remote-time
- write-out
- verbose
Example:
- --xattr -o storage $URL
---
# `--xattr`
Store metadata in the extended file attributes.
When saving output to a file, tell curl to store file metadata in extended
file attributes. Currently, `curl` is stored in the `creator` attribute,
the URL is stored in the `xdg.origin.url` attribute, for HTTP, the content
type is stored in the `mime_type` attribute, and if set, the referrer URL in
`user.xdg.referrer.url`. If the file system does not support extended
attributes, a warning is issued.
Since curl 8.22.0 this option is also supported on Windows, where it creates
an Alternate Data Stream named `Zone.Identifier`. It contains an INI formatted
`ZoneTransfer` section, with values: `HostUrl`, `ReferrerUrl` (if set).