Skip to content
Closed
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: 2 additions & 1 deletion gateway/platforms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ def _log_safe_path(path: str) -> str:

SUPPORTED_DOCUMENT_TYPES = {
".pdf": "application/pdf",
".ics": "text/calendar",
".md": "text/markdown",
".txt": "text/plain",
".csv": "text/csv",
Expand Down Expand Up @@ -1644,7 +1645,7 @@ def _log_safe_path(path: str) -> str:
# Audio (delivered as voice/audio where supported)
".mp3", ".m2a", ".wav", ".ogg", ".opus", ".m4a", ".flac",
# Documents (uploaded as file attachments)
".pdf", ".docx", ".doc", ".odt", ".rtf", ".txt", ".md", ".epub",
".pdf", ".ics", ".docx", ".doc", ".odt", ".rtf", ".txt", ".md", ".epub",
# Spreadsheets / data
".xlsx", ".xls", ".ods", ".csv", ".tsv", ".json", ".xml", ".yaml", ".yml",
# Geospatial / GIS (#24032)
Expand Down
30 changes: 30 additions & 0 deletions tests/gateway/test_media_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,36 @@ def extract_media_tags_broken(result_messages):
return media_tags, has_voice_directive


class TestMediaDeliveryExtensions:
"""Tests for the shared outbound media-delivery allowlist."""

def test_ics_media_tag_is_extracted_for_document_delivery(self):
"""Calendar invites should upload instead of rendering MEDIA: text."""
from gateway.platforms.base import BasePlatformAdapter

media, cleaned = BasePlatformAdapter.extract_media(
"Here is the calendar invite.\nMEDIA:/tmp/event.ics"
)

assert media == [("/tmp/event.ics", False)]
assert "MEDIA:" not in cleaned
assert "event.ics" not in cleaned

def test_ics_bare_path_is_allowed_for_document_delivery(self, tmp_path):
"""Bare local .ics paths should use the same delivery allowlist."""
from gateway.platforms.base import BasePlatformAdapter

invite_path = tmp_path / "event.ics"
invite_path.write_text("BEGIN:VCALENDAR\nEND:VCALENDAR\n")

files, cleaned = BasePlatformAdapter.extract_local_files(
f"The invite is at {invite_path}"
)

assert files == [str(invite_path)]
assert "event.ics" not in cleaned


class TestMediaExtraction:
"""Tests for MEDIA tag extraction from tool results."""

Expand Down