feat: parse document result packages from middle json only
Content comes from the middle json and its paired markdown; the content list is deliberately ignored because it escapes markdown characters. The external-data exception boundary covers both reading and structure parsing so no native exception escapes the OCR client. The layout parser is unchanged.
This commit is contained in:
@@ -190,7 +190,9 @@ class TestSniffMedia:
|
||||
pytest.param(b"GIF87a" + b"0" * 20, "image", id="gif87a"),
|
||||
pytest.param(b"RIFF\x00\x00\x00\x00WEBPVP8 ", "image", id="webp"),
|
||||
# 图片魔数优先: 含 XMP 元数据的图片可能在 1KB 内带 `%PDF-` 字样
|
||||
pytest.param(b"\xff\xd8\xff\xe0" + b"<xmp>%PDF-</xmp>", "image", id="jpeg-mentions-pdf"),
|
||||
pytest.param(
|
||||
b"\xff\xd8\xff\xe0" + b"<xmp>%PDF-</xmp>", "image", id="jpeg-mentions-pdf"
|
||||
),
|
||||
pytest.param(b"<html><body>paywall</body></html>", "unknown", id="html"),
|
||||
pytest.param(b"GARBAGE-NOT-AN-IMAGE", "unknown", id="garbage"),
|
||||
pytest.param(b"", "unknown", id="empty"),
|
||||
@@ -205,7 +207,9 @@ class TestSniffMedia:
|
||||
assert _upload_part(_PDF_BODY) == ("doc.pdf", _PDF_BODY, "application/pdf")
|
||||
assert _upload_part(_JUNK + _PDF_BODY)[0] == "doc.pdf"
|
||||
|
||||
@pytest.mark.parametrize("data", [b"\xff\xd8\xff\xe0abc", b"\x89PNG\r\n\x1a\nabc", b"junk", b""])
|
||||
@pytest.mark.parametrize(
|
||||
"data", [b"\xff\xd8\xff\xe0abc", b"\x89PNG\r\n\x1a\nabc", b"junk", b""]
|
||||
)
|
||||
def test_everything_else_keeps_the_legacy_label(self, data):
|
||||
"""非 PDF 路径字节级不变: 服务对图片按内容解码(2026-10-21 实测 PNG/TIFF/BMP 标 image.jpg 成功)。"""
|
||||
assert _upload_part(data) == ("image.jpg", data, "image/jpeg")
|
||||
|
||||
Reference in New Issue
Block a user