mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 03:30:40 +00:00
fix(weixin): check full 4-byte PNG magic signature (#2970)
PNG's magic bytes are 89 50 4E 47, but detectImageMime only checked
the first three. The WebP branch in the same function correctly checks
all four bytes of its signature — the PNG path was clearly an oversight.
Extend the PNG check to include 0x47 ('G') for consistency and to
eliminate the (admittedly rare) false-positive window.
This commit is contained in:
parent
c012462514
commit
9a420d0fce
1 changed files with 6 additions and 1 deletions
|
|
@ -205,7 +205,12 @@ export class WeixinChannel extends ChannelBase {
|
|||
|
||||
/** Detect image MIME type from magic bytes. */
|
||||
function detectImageMime(data: Buffer): string {
|
||||
if (data[0] === 0x89 && data[1] === 0x50 && data[2] === 0x4e) {
|
||||
if (
|
||||
data[0] === 0x89 &&
|
||||
data[1] === 0x50 &&
|
||||
data[2] === 0x4e &&
|
||||
data[3] === 0x47
|
||||
) {
|
||||
return 'image/png';
|
||||
}
|
||||
if (data[0] === 0x47 && data[1] === 0x49 && data[2] === 0x46) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue