DecodeBase64Output strips shell metadata and line-number prefixes from command output, then base64-decodes the result.
(output string)
| 316 | // DecodeBase64Output strips shell metadata and line-number prefixes from |
| 317 | // command output, then base64-decodes the result. |
| 318 | func DecodeBase64Output(output string) ([]byte, error) { |
| 319 | // 1. Strip shell metadata (exit code, wall time, "Output:" header). |
| 320 | cleaned := stripShellMetadata(output) |
| 321 | // 2. Strip line-number prefixes. |
| 322 | cleaned = StripReadToolLineNumbers(cleaned) |
| 323 | // 3. Remove all whitespace (base64 may be wrapped at 76 chars). |
| 324 | cleaned = strings.Join(strings.Fields(cleaned), "") |
| 325 | |
| 326 | if cleaned == "" { |
| 327 | return []byte{}, nil |
| 328 | } |
| 329 | |
| 330 | return base64.StdEncoding.DecodeString(cleaned) |
| 331 | } |