MDPack

MDPack conformance corpus

Packages for testing MDPack 0.1.0-draft implementations: 11 that a Conforming Reader must accept and 30 that it must reject.

Expected outcomes are machine-readable in expectations.json, so a test suite can iterate the corpus rather than hard-code a list. This page is generated from that file by tools/build-tests-readme.mjs; the packages themselves are generated by tools/build-corpus.mjs. Neither is meant to be edited by hand.

A rejection must name a reason. Reporting why a package was refused is what lets an application tell a user to upgrade rather than implying their file is corrupt, which is why §8.9 requires the failure modes to be distinguishable.

Error classes

Class Meaning
not-an-mdpack The file is not an MDPack package: unreadable as ZIP, no manifest, or the manifest does not identify itself as MDPack.
unsupported-version An MDPack package whose version the reader does not implement. Must be distinguishable from corruption so the user is told to upgrade.
malformed-manifest mdpack.json is present and identifies itself as MDPack but violates a structural requirement.
integrity-failure Package contents contradict themselves: checksum mismatch, byte-length mismatch, duplicate entries, truncation, or invalid UTF-8 in a text entry.
security-violation The package attempts something hostile, such as path traversal or an encrypted entry.
resource-limit Decompressing the package would exceed a reader resource limit.

Valid packages

Every one of these must be accepted.

Package What it covers
minimal.mdpack Manifest and document only, no assets.
with-assets.mdpack A PNG and a PDF, both referenced by relative path and both declared.
no-mimetype.mdpack Package without the mimetype entry.
required-members-only.mdpack A manifest carrying nothing but format, version, entrypoint and assets.
unknown-entries.mdpack Unknown entries and unknown manifest members that must survive a round trip.
untracked-asset.mdpack A file under assets/ that the manifest does not declare.
percent-encoded-asset.mdpack A Unicode asset name that must be percent-encoded in the Markdown reference.
fragment-reference.mdpack References carrying a fragment and a query component.
unknown-role.mdpack An asset declaring a role this specification does not define.
external-references.mdpack A document referencing only external URLs.
document-with-bom.mdpack document.md prefixed with a UTF-8 byte order mark.

Invalid packages

Every one of these must be rejected, with one of the listed error classes. A reader that accepts any of them is not conforming, and a reader that crashes on one is a liability: several of these files are what a hostile package looks like.

Package Why it is invalid Expected class
not-a-zip.mdpack Plain text with a .mdpack extension. not-an-mdpack
truncated-archive.mdpack A valid package cut off halfway through. not-an-mdpack or integrity-failure
missing-manifest.mdpack A ZIP containing document.md but no mdpack.json. not-an-mdpack
missing-document.mdpack Manifest present, document.md absent. malformed-manifest
wrong-format.mdpack format is “note” rather than “mdpack”. not-an-mdpack
missing-version.mdpack No version member. malformed-manifest
version-future.mdpack version is “9.0.0”. unsupported-version
missing-entrypoint.mdpack No entrypoint member. malformed-manifest
entrypoint-traversal.mdpack entrypoint is “../outside.md”. security-violation or malformed-manifest
missing-assets.mdpack No assets member. malformed-manifest
null-assets.mdpack assets is JSON null. malformed-manifest
assets-not-an-array.mdpack assets is an object rather than an array. malformed-manifest
asset-missing-entry.mdpack The manifest declares an asset the package does not contain. malformed-manifest
asset-outside-assets.mdpack A declared asset whose path is not under assets/. malformed-manifest
asset-duplicate-id.mdpack Two declared assets sharing an id. malformed-manifest
asset-missing-role.mdpack A declared asset with no role member. malformed-manifest
asset-bytes-mismatch.mdpack A declared asset whose bytes value does not match the stored length. integrity-failure
bad-mimetype-entry.mdpack A mimetype entry whose contents are wrong. not-an-mdpack
traversal-parent.mdpack Package holding an entry named “../evil.txt”. security-violation
traversal-absolute.mdpack Package holding an entry named “/etc/passwd”. security-violation
traversal-drive.mdpack Package holding an entry named “C:/evil.txt”. security-violation
traversal-nested.mdpack Package holding an entry named “assets/../../evil.txt”. security-violation
traversal-backslash.mdpack Package holding an entry named “..\evil.txt”. security-violation
duplicate-document.mdpack Two entries both named document.md. integrity-failure
duplicate-asset-entry.mdpack Two archive entries at assets/pixel.png differing only in case. integrity-failure
tampered-document-checksum.mdpack documentSha256 does not match document.md. integrity-failure
tampered-asset-checksum.mdpack An asset whose sha256 does not match its bytes. integrity-failure
declared-size-lie.mdpack The document entry declares an uncompressed size of 8 bytes but expands to far more. integrity-failure
invalid-utf8-document.mdpack document.md contains a byte sequence that is not valid UTF-8. integrity-failure
compression-bomb.mdpack An asset of 4 MiB of zero bytes, compressing at roughly 1000:1. resource-limit or integrity-failure

Regenerating

node tools/build-corpus.mjs       # packages and expectations.json
node tools/build-tests-readme.mjs # this page

The packages are byte-exact fixtures. .gitattributes pins *.mdpack as binary, because line-ending normalisation silently corrupts a ZIP archive and the corpus would then test nothing but the reader’s error paths.