Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions backend/services/attachment_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ def _is_hwpx_payload(payload: bytes) -> bool:

has_manifest = "Contents/content.hpf" in names or "META-INF/manifest.xml" in names
has_section = any(
name.startswith("Contents/section") and name.endswith(".xml")
for name in names
name.startswith("Contents/section") and name.endswith(".xml") for name in names
)
return (
mimetype == _HWPX_MIMETYPE
Expand Down
22 changes: 14 additions & 8 deletions backend/tests/test_attachment_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,13 @@ def test_hwpx_attachment_is_deferred_for_structured_xml_package():
assert result.parser_key == "hwpx"
assert result.parse_status == "hwpx_xml_package_pending"
assert result.parse_error_code is None
assert decode_deferred_attachment_payload(
result.content,
"application/hwp+zip",
) == raw
assert (
decode_deferred_attachment_payload(
result.content,
"application/hwp+zip",
)
== raw
)


@pytest.mark.parametrize("filename", ["proposal.hwpx", "proposal.owpml"])
Expand Down Expand Up @@ -377,10 +380,13 @@ def test_hwp_attachment_is_deferred_for_sandboxed_conversion():
assert result.parser_key == "hwp"
assert result.parse_status == "hwp_conversion_pending"
assert result.parse_error_code is None
assert decode_deferred_attachment_payload(
result.content,
"application/x-hwp",
) == raw
assert (
decode_deferred_attachment_payload(
result.content,
"application/x-hwp",
)
== raw
)


def test_hwp_extension_with_generic_content_type_is_deferred_pending():
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/test_attachment_parser_hwp_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def test_hwp_admission_accepts_ole_plus_hwp_file_header_signature() -> None:

def test_hwp_deferred_decoder_rechecks_hwp_file_header_signature() -> None:
"""Keep stored-payload decoding fail-closed after import-time admission."""
encoded = base64.b64encode(
_ole_payload(include_hwp_signature=False)
).decode("ascii")
encoded = base64.b64encode(_ole_payload(include_hwp_signature=False)).decode(
"ascii"
)

with pytest.raises(ValueError, match="not a HWP binary"):
parser.decode_deferred_attachment_payload(
Expand Down
4 changes: 1 addition & 3 deletions backend/tests/test_attachment_parser_hwpx_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def test_hwpx_recognition_bounds_aggregate_member_name_bytes(
"""Reject metadata expansion through many or very long member names."""
monkeypatch.setattr(parser, "MAX_HWPX_ZIP_NAME_BYTES", 32)

result = _parse_hwpx(
_hwpx_bytes(extra_entries=(f"Contents/{'x' * 64}.xml",))
)
result = _parse_hwpx(_hwpx_bytes(extra_entries=(f"Contents/{'x' * 64}.xml",)))

assert result.parse_status == "invalid_hwpx_payload"

Expand Down