* security(meta): linear entity decoding, indexed keyword de-duplication, bounded XMP path building
* address review: decode zero-padded numeric references in the three entity decoders
The pathname is checked before File::open as well as the opened file after it: File::open on a FIFO blocks until a writer appears, so the post-open check alone never ran for one. Adds a unix regression test that hung before the fix.
Use the same exact-score known-crop preference as best_lens in the built-in fixed-lens fallback. Preserve higher-score priority and cover both profile orders through the public lookup API.
Validated with 33 lensdb and 5 engine lens-profile tests, plus full cargo xtask ci (8/8, Rust 1.95.0, Apple M5 Max Metal and WASM). The new tie regression fails against the previously published selector. No workflows or lockfile changes.
Co-authored-by: Codex <noreply@openai.com>
Prefer a known calibration crop only on exact lens-score ties, preserving higher-score selection. Keep hostile numeric model fixtures active with valid calibration crop.
Co-authored-by: Codex <noreply@openai.com>
Merge upstream main at 496524ced5 without rewriting published history. Preserve current upstream fixes and retain only the independent feature change in the resulting PR diff.
Co-authored-by: Codex <noreply@openai.com>
find_lens_named no longer falls back to the camera's mount (it must stay an
exact-name match); a model without an EXIF make still finds the camera when
it starts with the maker's word; infinite focal lengths parsed from EXIF are
ignored and a non-finite widened range matches nothing. Review feedback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lensfun names a compact camera's built-in lens after the camera and gives it
the camera's own mount, while EXIF reports only a focal / aperture range
("6.0-72.0 mm f/2.7-3.5"), so no profile was found. When the name lookup finds
nothing, take the camera's mount (only when it has at most four profiles, i.e.
not an interchangeable mount) and pick the profile whose calibrated focal
lengths lie inside the EXIF range. Camera lookups also drop the maker's word
from model names ("Canon PowerShot S5 IS" matches "PowerShot S5 IS").
Adds a hostile-number test: infinite, NaN, huge or negative database values
give finite corrections or none, and odd names find nothing without panicking.
Sources: own design (lensfun XML format documentation).
(cherry picked from commit 24ebc3bea9)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found while testing crates/meta/src/xmp.rs:184 (entity); the same pattern is in crates/lensdb/src/xml.rs:45 and crates/engine/src/preset_luminar.rs:90
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keep missing and invalid camera/calibration crops optional. Only absent calibration overrides inherit the parent scale; decline corrections with unknown calibration scale and preserve EXIF fallback for unknown camera crops.
Add synthetic parser, conversion and engine regressions and document the contract. The crop-only patch is unchanged from a4064b33. Full cargo xtask ci passes all eight gates on current upstream main plus the separate #2544 prerequisite.
The mismatch mechanism is confirmed in code, but the current outcome is accidental: it works only because `TC-1.4x` contributes a numeric token absent from the base name. Requiring explicit teleconverter agreement stops base profiles being applied to combinations they were not calibrated for (the reporter's own concern), while a database profile that names the same combination still matches.
Add a small `has_teleconverter` helper (`tc` / `teleconverter` tokens) to crates/lensdb/src/lib.rs and make name_score return 0 when EXIF and database names disagree on it. Add one regression test in crates/lensdb/src/tests.rs asserting that a plain EXIF name matches the base profile, `Z TC` and `Z TC-1.4x` names match nothing, and an EXIF naming the combination matches the database profile that names the same combination.
Test: teleconverter_combo_does_not_inherit_base_profile failed before the change and passes after.
Another maker's lens with the same specification ("Otherco 18-55mm f/3.5-5.6")
scores as high as the profile aliased "18-55mm f/3.5-5.6"; when it came first,
find_lens kept it and the exact-name check then refused it, so the alias was
never used. LensDb::find_lens_named ranks only the profiles named exactly so,
with the same maker and mount preferences (review on #2217).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nikon DSLRs write no Exif LensModel, only the lens specification (maker note
0x0084, read into Metadata::lens_spec), so the lensfun-format lens database never
corrected their raws. A raw without a lens model is now looked up by a name built
from its specification ("24-70mm f/2.8", lightcraft_lensdb::spec_name), and a
profile is used only when one of its names is exactly that
(Profile::names_exactly): the specification fits every maker's lens with that
range, so a partial match or a maker-named entry is never taken. lensfun's own
database has no such names; a user aliases the one lens they own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lensfun profile is scaled by the crop factor of the recorded frame. `lookup` took the body's from the
database whenever the camera was in it, so a full-frame body shooting a crop of its sensor (APS-C /
Super 35 mode, or switched there by an APS-C lens) had the profile applied as if the crop were the full
frame: the crop's corners got the full frame's corner distortion and vignetting. On a Sony ILCE-1M2 in
APS-C mode with the FE 100-400mm F4.5-5.6 GM OSS at 400 mm, the warp's r³ coefficient was the full
frame's 0.0215 instead of 0.0096.
The 35 mm equivalent focal length shows the crop: when it implies a crop factor more than 10 % above the
body's, that wins (`frame_crop_factor`); within 10 % the difference is the tag's whole-millimetre
rounding and the body's value stands. Without the body in the database the 35 mm equivalent is used, as
before.
Tests: `in_camera_crop_mode_uses_the_frames_crop_factor` (fails on main: in its profile the APS-C frame's
vignetting gain is 0.40 instead of 0.18) covers APS-C mode, full frame, a 35 mm equivalent rounded by a
millimetre, no body in the database and a hostile focal length. Checked on 19 private ILCE-1M2 ARWs
(FE 100-400mm GM, Sigma 24-70mm F2.8 DG DN | Art, full frame and APS-C, firmware 2.01-4.00): every
APS-C coefficient is the full-frame one scaled by 1/1.5².
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Profiles are interpolated in focal length (vignetting also in aperture and
focus distance), scaled by crop factor, and converted by least squares to the
DNG WarpRectilinear / FixVignetteRadial polynomials the pipeline already
applies. The lensfun database (CC-BY-SA) is only read from a directory the
user supplies; nothing is bundled.
Sources: lensfun's published database format and lens calibration
documentation (no lensfun code read), PanoTools wiki (a, b, c distortion
model), DNG specification 1.6 (WarpRectilinear, FixVignetteRadial);
interpolation and fitting: own design.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>