Fix file extension mismatch detection logic false positives and negatives#77
Conversation
- Expanded `FormatExtRule` struct to support up to `alt5` alternatives to handle formats with many file extensions (e.g. PNM and TGA). - Reordered `g_formatRules` to evaluate compound and specific format strings (like "wbmp", "jpeg xl", "tinyexr", "libavif") before core formats (like "bmp", "jpeg", "exr"). This fixes false positive mismatch warnings where "wbmp" incorrectly matched the "bmp" rule via substring check. - Refactored matching loop to safely handle multiple alt conditions. - Downgraded `fmt.contains` to `fmt.find(...) != std::wstring::npos` for better compiler compatibility without altering logic.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Expanded `FormatExtRule` struct to support up to `alt5` alternatives to handle formats with many file extensions (e.g. PNM and TGA). - Reordered `g_formatRules` to evaluate compound and specific format strings (like "wbmp", "jpeg xl", "tinyexr", "libavif") before core formats (like "bmp", "jpeg", "exr"). This fixes false positive mismatch warnings where "wbmp" incorrectly matched the "bmp" rule via substring check. - Refactored matching loop to safely handle multiple alt conditions. - Downgraded `fmt.contains` to `fmt.find(...) != std::wstring::npos` for better compiler compatibility without altering logic. - Fixed `ImageEngine` missing propagation of `formatDetails` for SVGs across FastLane and `SafeCacheFrame` cache copies, preventing missing metadata downstream.
…adata for fast formats - Fix the constructor of `Toolbar` where the `FixExtension` button warning flag was hard-coded to `true` but skipped during layout, causing it to have a `0, 0, 0, 0` rect. - Added explicit call to `g_toolbar.UpdateLayout` immediately after `SetExtensionWarning` runs so the UI recalculates the bounds of the warning icon and it actually displays on screen when an extension is mismatched. - Fixed missing `formatDetails` string deep copy for SVG frames inside the `ImageEngine.cpp` FastLane processing to ensure accurate metadata is passed to the user interface.
- Correctly default `FixExtension` button `isWarning` flag to `false` so the UI knows it is hidden initially.
- Automatically call `g_toolbar.UpdateLayout` immediately after `SetExtensionWarning` assigns warning state, fixing the `{0,0,0,0}` button rect bug where the error icon would never be drawn even when correctly detected.
- Fixed `ImageLoader::LoadToFrame` missing metadata output `formatDetails` assignment for SVG files.
- Extended `FormatExtRule` array and structurally reorganized format string rules to evaluate exact and compound format strings before shorter matches to prevent substring detection false positives.
…ading channels (Scout, Heavy, RAW)
The issue requested fixing the file extension mismatch detection logic which was failing to display the correction icon (warning) on certain mismatched files or displaying it erroneously on correct ones.
Problem
The
CheckExtensionMismatchlogic inQuickView/main.cpprelied onfmt.contains(rule.format)evaluated linearly down theg_formatRulesarray. This resulted in cases where a valid format likeWBMPincorrectly triggered theBMPrule because"wbmp".contains("bmp")evaluates to true. Furthermore, some format strings provided by the image decoder backend likejpeg xl,tinyexr, orlibavifwere previously incorrectly stored as valid extensions in the array, making it impossible to detect if.jpgwas mismatched as.jxlbecause it would match earlier rules or fail incorrectly.Solution
wbmp,jpeg xl,tinyexr) and placed them at the top of theg_formatRulesarray. This prevents a substring match on shorter names likebmporjpegfrom triggering falsely.L"libavif") into proper format-matching entries with their respective primary extensions (like.avif).alt4andalt5fields to theFormatExtRulestruct to support file format families with many extensions (e.g. the TGA family.tga,.icb,.vda,.vstor the PNM family.pnm,.pgm,.ppm,.pbm).fmt.contains(...)withfmt.find(...) != std::wstring::nposto ensure better compatibility with C++17 while maintaining the same behavior.PR created automatically by Jules for task 6362394628477913948 started by @justnullname