util/RasterImageFormat.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include <QByteArray> | ||
| 3 | #include <QImageReader> | ||
| 4 | |||
| 5 | // Sprint 102 R-5.8-1: image bytes from mail, cards or the network decode only | ||
| 6 | // as these raster formats. Qt's image plugins (the portable runtime deploys | ||
| 7 | // imageformats/*.so) also read SVG, PDF, TGA, TIFF, ICNS and more: SVG | ||
| 8 | // reaches Qt SVG's renderer (CVE-2026-6210, fixed in Qt 6.11.1), PDF reaches | ||
| 9 | // PDFium through Qt PDF's image plugin, and none of them is needed for | ||
| 10 | // photos or map tiles. | ||
| 11 | namespace RasterImageFormat { | ||
| 12 | 549 | inline bool allowed(const QByteArray &format) { | |
| 13 |
1/1✓ Branch 2 → 3 taken 549 times.
|
549 | const QByteArray name = format.toLower(); |
| 14 |
8/12✓ Branch 4 → 5 taken 469 times.
✓ Branch 4 → 15 taken 80 times.
✓ Branch 6 → 7 taken 26 times.
✓ Branch 6 → 15 taken 443 times.
✓ Branch 8 → 9 taken 26 times.
✗ Branch 8 → 15 not taken.
✓ Branch 10 → 11 taken 26 times.
✗ Branch 10 → 15 not taken.
✓ Branch 12 → 13 taken 26 times.
✗ Branch 12 → 15 not taken.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 26 times.
|
575 | return name == "png" || name == "jpeg" || name == "jpg" || name == "gif" || name == "webp" || |
| 15 | 575 | name == "bmp"; | |
| 16 | 549 | } | |
| 17 | |||
| 18 | // Detects the reader's format from the content (never from a name) and | ||
| 19 | // tells whether it may be decoded. Call before size() or read(): only the | ||
| 20 | // format probe has looked at the bytes then. | ||
| 21 | 549 | inline bool accept(QImageReader &reader) { | |
| 22 | 549 | reader.setDecideFormatFromContent(true); | |
| 23 |
2/2✓ Branch 3 → 4 taken 549 times.
✓ Branch 4 → 5 taken 549 times.
|
549 | return allowed(reader.format()); |
| 24 | } | ||
| 25 | } // namespace RasterImageFormat | ||
| 26 |