mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 13:17:41 +00:00
image-codecs: correct the prefix length that detect documents for FF D8
For a buffer of only `FF D8`, `detect_prefix` answers `NeedBytes(4)`, a 4-byte prefix that includes the SOI, not 4 bytes after it.
This commit is contained in:
@@ -413,7 +413,7 @@ impl PrefixDetector {
|
||||
/// JPEG-LS is told from JPEG by the frame header that follows the marker segments, so `bytes`
|
||||
/// must reach that header; a buffer that ends before it is reported as [`Format::Jpeg`] when it
|
||||
/// starts with `FF D8 FF`, and a buffer of only `FF D8` matches no format. Use [`detect_prefix`] on
|
||||
/// a buffer that may hold only the start of a file: it asks for 4 bytes after `FF D8`.
|
||||
/// a buffer that may hold only the start of a file: for `FF D8` it asks for a 4-byte prefix.
|
||||
pub fn detect(bytes: &[u8]) -> Option<Format> {
|
||||
let b = bytes;
|
||||
if b.starts_with(b"\x89PNG\r\n\x1a\n") {
|
||||
|
||||
Reference in New Issue
Block a user