{"record":{"id":"177fa2945a781dbc","repo":"tonhowtf/omniget","slug":"formato-sem-limpeza-sem-perda-aqui-s-jpeg-png-e-webp","errorCode":null,"errorMessage":"formato sem limpeza sem perda aqui — só JPEG, PNG e WebP","messagePattern":"formato sem limpeza sem perda aqui — só JPEG, PNG e WebP","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/exif.rs","lineNumber":294,"sourceCode":"            if &fourcc == b\"VP8X\" && body.len() > start + 8 {\n                body[start + 8] &= !(0x08 | 0x04);\n            }\n        }\n        i = end;\n    }\n    let mut out = Vec::with_capacity(body.len() + 8);\n    out.extend_from_slice(b\"RIFF\");\n    out.extend_from_slice(&(body.len() as u32).to_le_bytes());\n    out.extend_from_slice(&body);\n    Ok(out)\n}\n\npub fn strip_bytes(data: &[u8]) -> anyhow::Result<Vec<u8>> {\n    match kind_of(data) {\n        Some(Kind::Jpeg) => strip_jpeg(data),\n        Some(Kind::Png) => strip_png(data),\n        Some(Kind::Webp) => strip_webp(data),\n        None => Err(anyhow!(\n            \"formato sem limpeza sem perda aqui — só JPEG, PNG e WebP\"\n        )),\n    }\n}\n\n#[derive(Debug, Clone, Deserialize)]\npub struct StripOptions {\n    pub inputs: Vec<String>,\n    /// Sobrescreve o arquivo original em vez de criar uma cópia limpa.\n    #[serde(default)]\n    pub in_place: bool,\n    #[serde(default)]\n    pub output_dir: String,\n    #[serde(default)]\n    pub suffix: String,\n}\n\n#[derive(Debug, Clone, Serialize)]","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/exif.rs#L276-L312","documentation":"Format whitelist in strip_bytes: the input bytes were sniffed, but only JPEG, PNG and WebP have lossless metadata-strip implementations; any other image kind (or undetectable data) reaches this guard and is refused rather than risk corrupt output.","triggerScenarios":"Calling strip_bytes with bytes whose leading magic is not FFD8 (JPEG), 89 50 4E 47 (PNG) or RIFF....WEBP — e.g. GIF, BMP, TIFF, HEIC, SVG, or an empty/garbage buffer.","commonSituations":"User drops an unsupported image type into a bulk EXIF-removal feature; file has wrong extension but is detected by content; input is actually HTML or a 0-byte file from a failed download.","solutions":["Check the file's real format (magic bytes) before calling and only pass JPEG/PNG/WebP","Convert unsupported formats to one of the supported ones first (e.g. via ffmpeg/ImageMagick)","Show a user-facing message listing supported formats instead of surfacing the raw error"],"exampleFix":"// before\nlet out = exif::strip_bytes(&bytes)?;\n// after\nlet out = match exif::strip_bytes(&bytes) {\n    Ok(o) => o,\n    Err(_) => return Err(anyhow!(\"arquivo nao suportado: use JPEG, PNG ou WebP\")),\n};","handlingStrategy":"validation","validationCode":"// rust\nfn is_supported_image(data: &[u8]) -> bool {\n    data.starts_with(&[0xFF, 0xD8])            // JPEG\n        || data.starts_with(&[0x89, b'P', b'N', b'G']) // PNG\n        || (data.len() > 12 && &data[0..4] == b\"RIFF\" && &data[8..12] == b\"WEBP\") // WebP\n}","typeGuard":null,"tryCatchPattern":"match exif::strip_bytes(&bytes) {\n    Ok(clean) => clean,\n    Err(e) => return Err(anyhow!(\"formato nao suportado (use JPEG/PNG/WebP): {e}\")),\n}","preventionTips":["Detect format by magic bytes, never by file extension","Filter or convert unsupported formats before batch EXIF removal","Handle 0-byte and HTML error-page bodies from failed downloads"],"tags":["unsupported-format","exif-stripping","magic-bytes"],"backgroundTag":"unsupported-operation","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}