You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(gmail): run PDF text extraction in a killable subprocess
Address the remaining review P1: a goroutine timeout cannot terminate
parser work, so repeated hostile PDFs could leave CPU/memory work behind
in a long-lived MCP server.
- gmail attachment --text now re-execs the gog binary as a hidden
`gmail pdf-extract` child (PDF bytes on stdin, text on stdout) under
exec.CommandContext, so the 10s timeout SIGKILLs the parser outright.
- Child re-checks the input size cap; parent caps extracted-text output
at 4 MiB (compressed streams can inflate past the input cap) and
surfaces child stderr as the failure reason.
- Tests spawn the real subprocess boundary (test binary dispatches via
a TestMain hook): extraction through the child, a hung child killed
on timeout, corrupt-PDF error propagation, direct child-command IO,
and oversized-input rejection.
Co-Authored-By: Claude Fable 5 <[email protected]>
Copy file name to clipboardExpand all lines: internal/cmd/gmail.go
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@ type GmailCmd struct {
27
27
28
28
SettingsGmailSettingsCmd`cmd:"" name:"settings" group:"Admin" help:"Settings and admin"`
29
29
30
+
PDFExtractGmailPDFExtractCmd`cmd:"" name:"pdf-extract" hidden:"" help:"Extract text from PDF bytes on stdin (internal: killable child for attachment --text)"`
0 commit comments