List the files inside an embedded text/html attachment - #346
Conversation
There was a problem hiding this comment.
Pull request overview
Enables attachment discovery within embedded HTML email bodies while preserving wrapper exclusion and bounded recursion.
Changes:
- Recursively extracts nested downloadable attachments.
- Adds extraction and recursion-limit tests.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/htmlutil/htmlutil.go |
Traverses embedded HTML when extracting attachments. |
internal/htmlutil/htmlutil_test.go |
Tests nested extraction and depth limiting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
An HTML email from outside HEY arrives as one <figure data-trix-attachment> with contentType "text/html" and the original markup in its content string (21751f9). When that email carried files -- an Outlook sender attaching two PDFs, say -- they sit inside that markup as <action-text-attachment> elements, so `hey attachment list` answered "0 attachments" for a thread whose `hey thread read` plainly showed the 📎 lines, and `hey attachment save` had nothing to address. findAttachments now walks into the embedded markup the way findImages already does, bounded by embeddedContentDepthLimit, and lists what it finds there. The wrapper itself is still not listed: an embedded body is not a downloadable file, and the test that says so still holds.
3447d76 to
578c0a3
Compare
|
Thanks @adammiribyan for tracking this down and opening the fix! The recursive extraction was exactly the right direction. I expanded the coverage for mixed direct and embedded files, nested wrappers, stable attachment IDs, saving embedded files, and safe blob-path handling. I also validated it against a real DigitalOcean invoice matching the reported failure: the released CLI found no attachments, while this PR found and successfully saved the PDF. Really appreciate the contribution! |
hey attachment listreturns 0 attachments for an inbound HTML email (Outlook and the like) even whenhey thread readshows the 📎 lines, sohey attachment savehas no ID to work with.Why: since 21751f9 such an email is one
text/htmltrix<figure>whosecontentstring holds the original markup.findAttachmentsstops at that figure; the<action-text-attachment>file elements are inside the markup.Fix:
findAttachmentsrecurses into the embedded markup the same wayfindImagesalready does, with the sameembeddedContentDepthLimit. The wrapper itself is still not listed (TestExtractAttachmentsSkipsEmbeddedHTMLAttachmentis unchanged).Review: one
switchinfindAttachmentsmirroring the one infindImages, plus two tests — the first fails onmain, the second pins the depth limit.make checkpasses.