Repository navigation
stop parsing bracketed suffix of input file path as loader options - #4642
Open
metsw24-max wants to merge 1 commit into
Open
metsw24-max wants to merge 1 commit into
metsw24-max wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.