Skip to content

OnlyWorlds Unity SDK 0.11.0

Choose a tag to compare

@tmoosting tmoosting released this 22 Oct 02:17
· 560 commits to main since this release

World archives follow the folder spec's .owworld section (§4.7): OWWorldArchive.Read (and so LoadInto and the
importer) agrees with the shared conformance fixture set on every one of its 78 cases, as the TypeScript SDK 4.49.0
does. A refusal names its cause from the spec's list, a mimetype marker is read, the default budget is the spec's
floor (500,000 files, 2 GiB), entry names are strict, two names that one disk would merge are found by Unicode simple
case folding pinned at 15.1.0, a world's api block is stripped on read, and Pack writes in code point order. A
minor release because it adds public API (below). Also here: the archive budget, a records producer's own files kept
whole, and entries refused that would not land safely on every disk.

Added

  • The .owworld marker (folder spec §4.7, OW-6): OWWorldArchive.MediaType is the file's media type,
    application/vnd.onlyworlds.world+zip. OWWorldArchive.Read (and so LoadInto and the importer) accepts an
    archive whose root holds a mimetype entry with exactly those bytes, never requires one, and refuses one that
    holds anything else (another type, a trailing newline, a BOM).
  • An .owworld refusal names its cause: OWFolderFormatException.Reason is set on every refusal from
    OWWorldArchive.Read (and so LoadInto and the importer) to one cause from folder spec §4.7's shared list,
    the constants of the new OWWorldArchiveReason (not_openable, not_a_world, more_than_one, unsafe_path,
    too_big, too_many, duplicate, collision, link, method, name, marker), the names the TypeScript
    reader and the conformance fixture set use. A folder's refusal leaves it null. The exception type is unchanged.

Changed

  • An .owworld is read within a budget: OWWorldArchive.Read and LoadInto (and so the importer) refuse an
    archive that holds more than 500,000 files or declares more than 2 GiB uncompressed, before inflating anything, and
    refuse one with an entry that inflates past the size it declares (a zip bomb's lie), so a hostile file cannot fill
    memory. The numbers are folder spec §4.7's floor (OW-15), the size every reader accepts, as
    OWWorldArchive.DefaultMaxBytes and DefaultMaxEntries; the new OWWorldArchiveReadOptions (MaxBytes,
    MaxEntries), passed to Read or LoadInto, lowers or raises them for one read. The TypeScript SDK's reader
    holds 1 GiB and 200,000 files today, below the floor. Its budget rule and test vectors are ported.
  • An .owworld entry name must be a plain relative path (folder spec §4.7, OW-16, ruled strict):
    OWWorldArchive.Read (and so LoadInto and the importer) refuses an archive with an entry name that holds a
    backslash, or has an empty, . or .. segment, whatever it would resolve to. Before, w\x.json,
    w//x.json, w/./x.json and w/a/../x.json were resolved and read; one name with two spellings is a file two
    readers can take for different entries. The TypeScript reader's rule.
  • A read strips an .owworld's api block (folder spec §4.7, OW-10): OWWorldArchive.Read (and so LoadInto
    and the importer) no longer returns it in World, so a world read from an archive is never IsSyncable and its
    ServerWorldId is its own id. The file is still read: refusing it would strand a person's own leaked copy. The
    TypeScript reader's behaviour. Pack's keepApiBlock: true still keeps the block, and its doc now says what the
    spec does: such a file is a private copy, not a portable .owworld.

Fixed

  • world.json's id must be a non-empty string, as the folder spec requires (§4.1): a folder read, an archive read
    and OWWorldArchive.Pack refuse an id that is a number, a boolean, a list or blank (" "). Before, 7 was read
    as the id "7" and a blank id passed. The TypeScript reader refuses the same.

  • OWWorldArchive.Pack keeps a producer's own x.meta beside its x in records/, byte for byte (§4.5 rule 6).
    It left out every .meta named after a file or folder beside it as Unity's; now only one that opens as Unity
    writes them (fileFormatVersion:, then a guid: line) is left out.

  • OWWorldArchive.Read (and so LoadInto and the importer) refuses an .owworld whose entries would not land
    safely on every disk, anywhere in the archive, not only in the world's folder:

    • two entries of one name (before, only inside the world's folder);
    • two names that are one once case and Unicode normalization (NFC) are ignored, files or folders (Ana.json
      beside ana.json; café in NFC beside NFD; Elements/ beside elements/): one file on Windows and macOS.
      The fold is the one folder spec §4.7 rules for every reader (OW-18): NFC, then Unicode simple case folding
      (CaseFolding.txt's C and S rows at Unicode 15.1.0, the version the spec pins, so every reader folds the same
      letters), from a table generated by tools/gen_casefold.py from the copy the conformance fixture set vendors,
      so it is the same on every runtime and never the runtime's culture data. So ς meets σ, ſ meets s and
      Cherokee's small letters meet its capitals, while ß stays apart from ss and the Turkic İ and ı from i;
      upper-then-lower casing, which Mono gets wrong on 484 code points at 15.1.0, is not used;
    • a path that is both a file and a folder (w/media beside w/media/a.png);
    • a symbolic link or special file, by the Unix mode in the entry's external attributes;
    • an encrypted entry, by its flag (ZipCrypto was refused only because its header made the size wrong), and an
      entry in a method other than stored or deflate (LZMA, deflate64, bzip2): before, an element the runtime could
      not inflate was skipped and the read went on, and deflate64 was read where the runtime could;
    • a Windows device name as a name's stem, with or without an extension (CON.json, nul.txt, COM1-COM9,
      LPT1-LPT9), a name ending in a dot or a space, the characters <>:"|?* or a control character;
    • a non-ASCII name without the zip's UTF-8 flag, whose spelling is a guess, and a name with the flag whose bytes
      are not UTF-8 (the runtime read them as U+FFFD, another name than the one written);
    • a stored entry whose stored size differs from the size it declares: holding more is the zip bomb's lie, refused
      from the directory alone, so in media/ too, which is never read.

    And a second world.json inside the world (w/inner/world.json) is refused as a second world; one under
    records/ stays a producer's own data. The TypeScript reader also refuses a file-and-folder path and a nested
    world.json; it has none of the other checks yet. Each refusal names the entry and why.

  • OWWorldArchive.Pack writes entries in the order of their names' UTF-8 bytes (code point order), as folder spec
    §4.7 rules (OW-13). It sorted UTF-16 code units, which put a name past U+FFFF (an emoji) before one from U+E000
    to U+FFFF (a fullwidth letter), so two writers given one world wrote different bytes.