Skip to content

stop parsing bracketed suffix of input file path as loader options - #4642

Open
metsw24-max wants to merge 1 commit into
lovell:mainfrom
metsw24-max:input-path-literal
Open

metsw24-max wants to merge 1 commit into
lovell:mainfrom
metsw24-max:input-path-literal

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

a string input is passed as-is to vips_foreign_find_load and VImage::new_from_file, and both split a trailing bracketed suffix off the path and apply it as loader options, ahead of sharp's own options, so anything sharp does not set explicitly is honoured. sharp('photo.jpg[shrink=8]') loads photo.jpg at an eighth of its size and metadata() reports those dimensions, and sharp('large.svg[unlimited=true]') loads an 11 MB svg that is otherwise rejected, which quietly undoes the unlimited: false default wherever a caller forwards a path it did not build itself. the same parsing means a real file whose name ends in ']' cannot be opened at all. OpenInput now looks the loader up with the literal path via vips_foreign_map, mirroring the vips_foreign_find_load lookup minus the split, and calls it directly with sharp's options, so the suffix form is never interpreted; the shrink-on-load reload paths already call jpegload and friends with the literal filename, so this brings the initial open into line with them. the missing-file check moves to vips_existsf rather than matching the libvips error text, which is translatable.

reviewer note: most bracket options were already overridden by sharp's explicit settings, so i doubt anyone relies on the suffix syntax, but it is a behaviour change that probably deserves a changelog line. regression tests in test/unit/io.js; full suite green, cpplint, biome and cspell clean.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant