---
url: /en-us/standard/file/extra.md
---
**The resource package `filename.uink.extra` is an ordinary ZIP file** that stores the images, SVGs, PDFs, audio and video referenced by Media. It is only a container for resources: the position, size, order and undo information of resources are all recorded in the [Media blocks](../blocks/media) of the main file, and the ZIP has no extra index.

::: tip Levels
Readers need to read the resource package from Standard (images) up; Core and Basic readers may ignore it completely.
:::

## Files

::: file-tree

* lesson.uink MessagePack main file
* lesson.uink.extra ZIP resource package, optional
  * images
    * diagram.png
  * documents
    * handout.pdf

:::

* **EXTRA-1** The resource package has the same name as the main file with an additional `.extra` extension, and is placed in the same directory.
* **EXTRA-2** The resource package may be absent. The main file is always the authoritative source of the content; when the resource package is missing, strokes and shapes must be displayed as usual.

## Resource paths

* **EXTRA-3** `Media.path` is a relative path under the ZIP root, separated by `/`, and normalized to Unicode NFC before writing.
* **EXTRA-4** A path must not start with `/`, and must not be a URI, a drive-letter path or any other absolute path; it must not contain `\`, NUL, control characters, empty path segments, `.` or `..`.
* **EXTRA-5** ZIP entry names use the same normalization rules. When entry names are duplicated after normalization, the resources involved are all treated as unavailable; a reader must not pick one of them and continue.

## Safe reading

The resource package may come from an untrusted source.

* **EXTRA-6** Readers must not extract the resource package directly into the working directory.
* **EXTRA-7** Before reading any entry, allocating buffers or starting a decoder, check the resource budget first: at least the number of entries, the size of a single entry, the total uncompressed size and the compression ratio. The specific values are up to the app.
* **EXTRA-8** Keep accumulating the actual usage while decompressing and decoding as a stream; readers must not rely solely on the sizes declared in the ZIP. Stop immediately when any budget is exceeded, and treat that resource as missing.
* **EXTRA-9** SVG must be treated as a static image: disable scripts, event handlers, external network resources, external file references and any other executable content; if it cannot be safely downgraded, do not display the resource.
* **EXTRA-10** When the `mimeType` is unknown, clearly disagrees with the result of content sniffing, or the decoder rejects the content, the resource is treated as unavailable.

## Missing resources

* **EXTRA-11** When the resource package does not exist, an entry does not exist or a resource is unavailable, the reader keeps the position and order of the Media and indicates that the resource is missing; whether to draw a placeholder box is up to the app. An error in one resource must not affect other content.

## Commit order

During a full save, the main file and the resource package are replaced in order, so that at any moment the old main file can still find the resources it needs.

* **EXTRA-12** Determine the set of resources the new main file will reference.
* **EXTRA-13** Generate a temporary resource package containing the **union** of the resources referenced by the old main file and the new main file, and verify it.
* **EXTRA-14** Generate and verify the temporary main file, but do not use it to replace the existing main file yet.
* **EXTRA-15** First replace the target resource package with the temporary resource package, and atomically replace the main file last.
* **EXTRA-16** Only after the main file has been replaced successfully may entries that are no longer referenced, or the whole resource package, be deleted; extra resources left behind by a crash may be cleaned up later.
* **EXTRA-17** When the content of a resource at the same path changes, a writer should use a new path (for example by including a content digest in the file name), so that the old main file does not read the new content before the replacement is complete.

## Related

* [Media Block](../blocks/media)
* [Saving, Appending and Recovery](../incremental)
