Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
steps:
- uses: actions/checkout@v7.0.1

- uses: jdx/mise-action@v5.4.0
- uses: jdx/mise-action@v5.5.0
with:
install_args: actionlint shellcheck github:standards-lab/claude-plugins

Expand All @@ -115,7 +115,7 @@ jobs:
steps:
- uses: actions/checkout@v7.0.1

- uses: jdx/mise-action@v5.4.0
- uses: jdx/mise-action@v5.5.0
with:
install_args: go golangci-lint

Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
if: hashFiles(format('tools/{0}/*.slnx', matrix.tool)) != ''
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang zlib1g-dev

- uses: jdx/mise-action@v5.4.0
- uses: jdx/mise-action@v5.5.0
with:
working_directory: tools/${{ matrix.tool }}

Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
steps:
- uses: actions/checkout@v7.0.1

- uses: jdx/mise-action@v5.4.0
- uses: jdx/mise-action@v5.5.0
with:
install_args: go

Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
- name: Install the NativeAOT prerequisites
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang zlib1g-dev

- uses: jdx/mise-action@v5.4.0
- uses: jdx/mise-action@v5.5.0
with:
working_directory: tools/ooxml

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
if: hashFiles(format('tools/{0}/*.slnx', needs.tag.outputs.format)) != ''
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang zlib1g-dev

- uses: jdx/mise-action@v5.4.0
- uses: jdx/mise-action@v5.5.0
with:
working_directory: tools/${{ needs.tag.outputs.format }}

Expand Down
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@ tool under `tools/` keeps its own.

## [Unreleased]

## [v0.13.0] - 2026-12-02

This release adds `route.MediaType`, the media type of content as `route.At` routes it, on `At`'s
inputs, so a caller takes a media type and a route from one reading of the content. It also moves
`picture.LibreOfficeImage` to gotenberg 9.11.1.

### Added

- `route.MediaType(r, size, head, name, mimeType)`, the media type of content as `route.At` routes
it: a `route.Kind`'s type by its signature, such as application/pdf, application/zip for a ZIP or
an ODF package, and application/x-ole-storage for an OLE2 compound file; within a ZIP, an ODF
package, or an OLE2 compound file, the name's extension, by `route.Ext`, first: an OOXML type for
an extension `route.OOXMLExtension` reports, an OpenDocument type for .odt, .ods, .odp, or .odg
and application/zip for .zip within a ZIP or ODF package, and a legacy office type for an
extension `route.LegacyTarget` converts and application/vnd.ms-outlook for .msg within an OLE2
compound file; and, for content of no signature, text/plain when it routes `route.Text`,
message/rfc822 when it routes `route.Nested`, and application/octet-stream otherwise. It returns
an error only for the reader's own.

### Changed

- `picture.LibreOfficeImage` is `gotenberg/gotenberg:9.11.1-libreoffice`, from 9.10.3-libreoffice,
pinned by its multi-arch index digest.

## [v0.12.0] - 2026-11-29

This release lets `stages.Build` run soffice on the host, so a host without a docker socket has the
Expand Down Expand Up @@ -721,7 +745,8 @@ fixtures scripts stay in the spike.
The [limits page](docs/limits.md) states them: each stage's tool's limits, docproc-ooxml's
behavior under a memory bound, the Threader's memory, and the formats no stage reads.

[Unreleased]: https://github.com/standards-lab/docproc/compare/v0.12.0...HEAD
[Unreleased]: https://github.com/standards-lab/docproc/compare/v0.13.0...HEAD
[v0.13.0]: https://github.com/standards-lab/docproc/compare/v0.12.0...v0.13.0
[v0.12.0]: https://github.com/standards-lab/docproc/compare/v0.11.0...v0.12.0
[v0.11.0]: https://github.com/standards-lab/docproc/compare/v0.10.0...v0.11.0
[v0.10.0]: https://github.com/standards-lab/docproc/compare/v0.9.0...v0.10.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags.
## Install

```sh
go get github.com/standards-lab/docproc@v0.12.0
go get github.com/standards-lab/docproc@v0.13.0
```

The module's releases are tagged `vX.Y.Z`, and [`CHANGELOG.md`](CHANGELOG.md) states what each
Expand Down
3 changes: 3 additions & 0 deletions cmd/docproc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ postgres modules, and each system tool under `tools/` keep their own.
stays beside its `export_test.go`. The command line, run directory, and exit codes don't change.
- `mise run build` at the repository root writes the docproc command to the git-ignored
`bin/docproc`.
- The module requires the docproc base module at v0.12.0, from v0.11.0, whose
[CHANGELOG](../../CHANGELOG.md) states its changes in full.
- The module requires go-core v0.15.0, from v0.14.0; nothing `docproc run` does changes with it.

## [v0.2.9] - 2026-11-28

Expand Down
4 changes: 2 additions & 2 deletions cmd/docproc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/standards-lab/docproc/cmd/docproc
go 1.27.4

require (
github.com/standards-lab/docproc v0.11.0
github.com/standards-lab/docproc v0.12.0
github.com/standards-lab/go-cli-sdk v0.4.0
github.com/standards-lab/go-core v0.14.0
github.com/standards-lab/go-core v0.15.0
golang.org/x/sys v0.50.0
)

Expand Down
8 changes: 4 additions & 4 deletions cmd/docproc/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/standards-lab/docproc v0.11.0 h1:TC1Q+IMZbf2KKkpMuUrjN5Fe5cn2Dftyegh7sCuDlxg=
github.com/standards-lab/docproc v0.11.0/go.mod h1:ZA8JYQPooA6YA84b00Lpu5AiSL2VSj/u7QnenltqVBA=
github.com/standards-lab/docproc v0.12.0 h1:fKof6WCaze3tu+sCI5cx3OgsH5s86Aus65DBsQNA0Mg=
github.com/standards-lab/docproc v0.12.0/go.mod h1:ZA8JYQPooA6YA84b00Lpu5AiSL2VSj/u7QnenltqVBA=
github.com/standards-lab/go-cli-sdk v0.4.0 h1:232dyKPD5kqshp0BMEVEZaedwJfvnDVqWLv7m1NQWmI=
github.com/standards-lab/go-cli-sdk v0.4.0/go.mod h1:7Y1BCcHtuu8Unxc+Hryjlln+0fbiMYa5xY75aueJ/rY=
github.com/standards-lab/go-core v0.14.0 h1:n8FRpoCqE0HErfo5V1iWASipo3ORx36V6ESQhgFZ27E=
github.com/standards-lab/go-core v0.14.0/go.mod h1:Yl/R+gM9YWczsePBCKXdPGh3FSdZ/5i8SapLIh3BDHU=
github.com/standards-lab/go-core v0.15.0 h1:yYjuUDlI7CupvtHJMT9Db7dAzNug3QJPGAEVruhIJI8=
github.com/standards-lab/go-core v0.15.0/go.mod h1:Yl/R+gM9YWczsePBCKXdPGh3FSdZ/5i8SapLIh3BDHU=
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
Expand Down
24 changes: 14 additions & 10 deletions cmd/docproc/internal/app/test/bounds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ var boundVars = []string{
func startingBounds() settings.Run {
return settings.Run{
Stages: stages.Options{
Memory: 2 * gib,
Timeout: 10 * time.Minute,
Idle: 2 * time.Minute,
Inspect: inspect.Options{BombRatio: 1000, BombSize: 1 * gib, Entries: 100_000},
Concurrency: 1,
Document: document.ImagesRequest{DPI: 150, Text: true, MaxPixels: 64_000_000},
Video: media.Request{MaxSide: 2048},
Magick: picture.Limits{Area: 256_000_000, Memory: 1 * gib, Map: 2 * gib, Disk: 8 * gib},
Audio: audio.Request{Limit: 30 * time.Second},
Memory: 2 * gib,
LibreOfficeMemory: 2 * gib,
Timeout: 10 * time.Minute,
Idle: 2 * time.Minute,
Inspect: inspect.Options{BombRatio: 1000, BombSize: 1 * gib, Entries: 100_000},
Concurrency: 1,
Document: document.ImagesRequest{DPI: 150, Text: true, MaxPixels: 64_000_000},
Video: media.Request{MaxSide: 2048},
Magick: picture.Limits{Area: 256_000_000, Memory: 1 * gib, Map: 2 * gib, Disk: 8 * gib},
Audio: audio.Request{Limit: 30 * time.Second},
},
Limits: dispatch.Limits{Parts: 100_000, Bytes: 32 * gib, Depth: 16},
Release: 10 * time.Second,
Expand Down Expand Up @@ -119,7 +120,10 @@ func TestBounds_EachVariableOverridesItsBound(t *testing.T) {
name, value string
set func(*settings.Run)
}{
{"DOCPROC_TOOL_MEMORY", "536870912", func(b *settings.Run) { b.Stages.Memory = 512 << 20 }},
{"DOCPROC_TOOL_MEMORY", "536870912", func(b *settings.Run) {
b.Stages.Memory = 512 << 20
b.Stages.LibreOfficeMemory = 512 << 20
}},
{"DOCPROC_UNIT_TIMEOUT", "90s", func(b *settings.Run) { b.Stages.Timeout = 90 * time.Second }},
{"DOCPROC_STREAM_IDLE", "1m30s", func(b *settings.Run) { b.Stages.Idle = 90 * time.Second }},
{"DOCPROC_MAX_PARTS", "50", func(b *settings.Run) { b.Limits.Parts = 50 }},
Expand Down
2 changes: 1 addition & 1 deletion compose/seaweedfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The harness's SeaweedFS S3 gateway, for the storage module's live tier.
# See docs/development.md
FROM chrislusf/seaweedfs:4.55
FROM chrislusf/seaweedfs:4.56

ENV AWS_ACCESS_KEY_ID=admin \
AWS_SECRET_ACCESS_KEY=secret
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Route string // document, office, vision, vision-converted, nested, onenot
func Identify(head []byte) Kind // at most HeadLen (4096) bytes
func File(path, name, mimeType string) (Route, string, error) // the route, and why
func At(r io.ReaderAt, size int64, head []byte, name, mimeType string) (Route, string, error)
func MediaType(r io.ReaderAt, size int64, head []byte, name, mimeType string) (string, error)
func Ext(name string) string // trimmed and lowercased
func EncryptedPackage(r io.ReaderAt, size int64) (bool, error) // an OLE2 EncryptedPackage
func RARVolume(head []byte) bool // a RAR's main header marks a volume
Expand Down
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ task.run_auto_install = false

[tools]
"aqua:google/go-containerregistry" = "0.22.1"
"github:standards-lab/claude-plugins" = { version = "0.25.0", version_prefix = "marathon/v" }
"github:standards-lab/claude-plugins" = { version = "0.26.0", version_prefix = "marathon/v" }
"github:ip7z/7zip" = "26.06"
actionlint = "1.7.12"
go = "1.27.4"
Expand Down
4 changes: 2 additions & 2 deletions picture/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const LibreOfficeMinimum = "24.2"
// runs in it under the runner's full lockdown, with no relaxation, so
// tool.Image{Ref: LibreOfficeImage} is the whole of it. A caller may run another image, or soffice
// on the host through the exec runner.
const LibreOfficeImage = "gotenberg/gotenberg:9.10.3-libreoffice@sha256:" +
"bf3efd63f83fa2ae3f9a8b422aca28984f696a31df94d3159059a1d2c296cc99"
const LibreOfficeImage = "gotenberg/gotenberg:9.11.1-libreoffice@sha256:" +
"e33b622c3bdea412eed6790d4e9cf0c63aa356157703409f9052a6b11ca6e08f"

// LibreOfficeSpec declares LibreOffice's soffice, minimum 24.2, for either runner's constructor;
// the container runner makes it the entrypoint in place of the image's own. soffice --version
Expand Down
2 changes: 2 additions & 0 deletions postgres/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ each system tool under `tools/` keep their own.

- The module's unit tests and integration suite sit in its `test/` directory as an external test
package. No exported API changes.
- The module requires the docproc base module at v0.12.0, from v0.11.0, and passes its
`dispatchtest.Index` suite; its [CHANGELOG](../CHANGELOG.md) states the base module's changes.

## [v0.1.9] - 2026-11-28

Expand Down
2 changes: 1 addition & 1 deletion postgres/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.27.4

require (
github.com/jackc/pgx/v5 v5.13.0
github.com/standards-lab/docproc v0.11.0
github.com/standards-lab/docproc v0.12.0
github.com/standards-lab/sqlate v0.8.0
github.com/standards-lab/sqlate/postgres v0.9.0
)
Expand Down
4 changes: 2 additions & 2 deletions postgres/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/jackc/puddle/v2 v2.2.3 h1:f8HoREISb3l5eO9coPgK7U3hKLhWGokOFVcThl5jrao
github.com/jackc/puddle/v2 v2.2.3/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/standards-lab/docproc v0.11.0 h1:TC1Q+IMZbf2KKkpMuUrjN5Fe5cn2Dftyegh7sCuDlxg=
github.com/standards-lab/docproc v0.11.0/go.mod h1:ZA8JYQPooA6YA84b00Lpu5AiSL2VSj/u7QnenltqVBA=
github.com/standards-lab/docproc v0.12.0 h1:fKof6WCaze3tu+sCI5cx3OgsH5s86Aus65DBsQNA0Mg=
github.com/standards-lab/docproc v0.12.0/go.mod h1:ZA8JYQPooA6YA84b00Lpu5AiSL2VSj/u7QnenltqVBA=
github.com/standards-lab/sqlate v0.8.0 h1:G1uUIWmc2DxJz5YhtBvIlftfURnb3b2RKsYB59Wa03Y=
github.com/standards-lab/sqlate v0.8.0/go.mod h1:pikNmGf/z3x46SBWFXgt/xKIDZuquSgCoXy5OWBFFR4=
github.com/standards-lab/sqlate/postgres v0.9.0 h1:l6PXEZ3GQM4+0zekxlSONhyHjpQU8g8StAS16bBqzZE=
Expand Down
5 changes: 5 additions & 0 deletions route/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
// [VisionConverted], [Nested], [OneNote], [Archive], [Audio], [Video], [Text], or
// [Unrouted].
// - [File] routes the file at a path, and says why; [At] routes content already open.
// - [MediaType] gives the media type of content as At routes it, on At's inputs: a [Kind]'s
// type by its signature; within a ZIP, an ODF package, or an OLE2 compound file, the name's
// extension first, for an OOXML, OpenDocument, or legacy office type, .msg's, or .zip's; and,
// for content of no signature, text/plain, message/rfc822, or application/octet-stream by
// its route.
// - [Ext] reads a name's extension; [OOXMLExtension] reports whether it is an OOXML
// package's, the one table of them; [LegacyTarget] gives the OOXML format a legacy
// extension converts to, the one table of those; [EncryptedPackage] reports whether an OLE2
Expand Down
130 changes: 130 additions & 0 deletions route/media.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package route

import "io"

const (
textPlain = "text/plain"
octetStream = "application/octet-stream"
zipType = "application/zip"
)

var kindTypes = map[Kind]string{
PDF: "application/pdf",
PNG: "image/png",
JPEG: "image/jpeg",
GIF: "image/gif",
BMP: "image/bmp",
TIFF: "image/tiff",
EMF: "image/emf",
WMF: "image/wmf",
SVG: "image/svg+xml",
HEIC: "image/heic",
WebP: "image/webp",
AVIF: "image/avif",
ZIP: zipType,
OLE2: "application/x-ole-storage",
ODF: zipType,
RTF: "application/rtf",
WordPerfect: "application/vnd.wordperfect",
PST: "application/vnd.ms-outlook-pst",
OST: "application/vnd.ms-outlook-pst",
Mbox: "application/mbox",
OneStore: "application/onenote",
MSCF: "application/vnd.ms-cab-compressed",
WAV: "audio/wav",
FLAC: "audio/flac",
MP3: "audio/mpeg",
Ogg: "audio/ogg",
M4A: "audio/mp4",
MP4: "video/mp4",
MKV: "video/x-matroska",
WebM: "video/webm",
AVI: "video/x-msvideo",
MPEGPS: "video/mpeg",
OggVideo: "video/ogg",
Gzip: "application/gzip",
Zstd: "application/zstd",
SevenZip: "application/x-7z-compressed",
Tar: "application/x-tar",
RAR4: "application/vnd.rar",
RAR5: "application/vnd.rar",
XZ: "application/x-xz",
Bzip2: "application/x-bzip2",
PE: "application/vnd.microsoft.portable-executable",
ELF: "application/x-executable",
MachO: "application/x-mach-binary",
Shebang: textPlain,
UTF8BOM: textPlain,
UTF16BOM: textPlain,
UTF32BOM: textPlain,
}

var zipTypes = map[string]string{
".zip": zipType,
".odt": "application/vnd.oasis.opendocument.text",
".ods": "application/vnd.oasis.opendocument.spreadsheet",
".odp": "application/vnd.oasis.opendocument.presentation",
".odg": "application/vnd.oasis.opendocument.graphics",
}

var legacyTypes = map[string]string{
"docx": "application/msword",
"xlsx": "application/vnd.ms-excel",
"pptx": "application/vnd.ms-powerpoint",
}

const outlookType = "application/vnd.ms-outlook"

// MediaType returns the media type of content r holds, size bytes, whose first bytes are head,
// at most [HeadLen] of them, as [At] routes it, taking At's inputs, so a media type and a route
// come from one reading of the content. Within a ZIP, an ODF package, or an OLE2 compound file,
// name's extension, by [Ext], decides first: an OOXML type for an extension [OOXMLExtension]
// reports; an OpenDocument type for .odt, .ods, .odp, or .odg, and application/zip for .zip,
// within a ZIP or an ODF package; and, within an OLE2 compound file, a legacy office type for an
// extension [LegacyTarget] converts, application/msword, application/vnd.ms-excel, or
// application/vnd.ms-powerpoint, or application/vnd.ms-outlook for .msg. Otherwise the [Kind]
// head's signature names decides, such as application/pdf for a [PDF], application/zip for a ZIP
// or an ODF package, application/x-ole-storage for an OLE2 compound file, application/mbox for an
// mbox, and text/plain for a script or a byte order mark. Content of no signature takes the route
// At gives it, with name and mimeType: text/plain for [Text], message/rfc822 for [Nested], and
// application/octet-stream otherwise. It returns an error only for r's own.
func MediaType(r io.ReaderAt, size int64, head []byte, name, mimeType string) (string, error) {
head = head[:min(len(head), HeadLen)]
kind := Identify(head)
if t := containerType(kind, Ext(name)); t != "" {
return t, nil
}
if t, ok := kindTypes[kind]; ok {
return t, nil
}
routed, _, err := At(r, size, head, name, mimeType)
if err != nil {
return "", err
}
switch routed {
case Text:
return textPlain, nil
case Nested:
return "message/rfc822", nil
}
return octetStream, nil
}

func containerType(kind Kind, ext string) string {
switch kind {
case ZIP, ODF:
if t, ok := ooxmlTypes[ext]; ok {
return t
}
return zipTypes[ext]
case OLE2:
if t, ok := ooxmlTypes[ext]; ok {
return t
}
if ext == ".msg" {
return outlookType
}
return legacyTypes[LegacyTarget(ext)]
}
return ""
}
Loading