WICG / WICG/webpackage

file format detection

Open
#528 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.3k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

in https://wicg.github.io/webpackage/draft-yasskin-wpack-bundled-exchanges.html#rfc.section.3.3

  1. If reading 10 bytes from stream returns an error or doesn’t return the bytes with hex encoding “86 48 F0 9F 8C 90 F0 9F 93 A6” (the CBOR encoding of the 6-item array initial byte and 8-byte bytestring initial byte, followed by 🌐📦 in UTF-8), return a “format error”.

I think this will cause implements like below

head = read_first_10_byte(path)

if (head == [86 48 F0 9F 8C 90 F0 9F 93 A6]) {
  // this is web bundle
  switch (parse_cbor(path)['version']) {
    // version switch
  }
} else {
  // this is not web bundle
}

but if webbundle format will change like below in the future. and also version ++.

webbundle = [
  magic
  version // *2*
  primary-url
  section-lengths
  sections
  extension // *new*
  length
]

the length of array will increase and first 10 byte will change.

this cause previous code not working, should be like this

head = read_first_10_byte(path)

if (head == [86 48 F0 9F 8C 90 F0 9F 93 A6]) {
  // this is web bundle
  switch (parse_cbor(path)['version']) {
    // version switch
  }
} else if (head == [*87* 48 F0 9F 8C 90 F0 9F 93 A6]
  // this is also new web bundle
  switch (parse_cbor(path)['version']) {
    // version switch
  }
} else {
  // this is not web bundle
}

so, this version model is not allow adding meta-section to webbundle cbor array.
if you think cbor array should not change from 6 forever, it works.
but I think it seems better to find other way to

  1. magic number should usable for file detection
  2. cbor structure update could detect by version, and not affect to 1

for example

webbundle = [
  magic
  body
  length
]

body = [
  version
  primary-url
  section-lengths
  sections
]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading section 3.3 of the linked Web Packaging specification and compare its fixed initial-byte detection with the proposed magic/body/length structure. Done would require an agreed format-detection and versioning design; the issue names no implementation entry point or tests.

Written by the indexing model from the issue text.

Assessment

Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.