Commit a095720
fix(files): keep url fallback and validate base64 canonically
Empty inline data no longer shadows a url. `''` and an empty Buffer now
produce a zero-byte buffer, which made `if (!buffer && data.url)` skip a
download that previously ran, so a tool emitting a placeholder alongside a
real url would have stored an empty file.
Replace the hand-rolled zero-length base64 check with the shared
`isCanonicalBase64`. `Buffer.from(x, 'base64')` silently drops characters
outside the alphabet, so `a!b!c!AAAA` and the non-canonical `AAAAA` decoded
to plausible-looking bytes instead of failing. Normalize first so the
payloads that already worked keep working: line-wrapped MIME base64,
unpadded base64url, and a base64 `data:` URI.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VxZCGfFjZnokR8uFeWrfLp1 parent 8a2844c commit a095720
2 files changed
Lines changed: 59 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 127 | + | |
135 | 128 | | |
136 | 129 | | |
137 | 130 | | |
| |||
159 | 152 | | |
160 | 153 | | |
161 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
162 | 195 | | |
163 | 196 | | |
164 | 197 | | |
| |||
171 | 204 | | |
172 | 205 | | |
173 | 206 | | |
174 | | - | |
| 207 | + | |
175 | 208 | | |
176 | 209 | | |
177 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
19 | 32 | | |
20 | 33 | | |
21 | 34 | | |
| |||
170 | 183 | | |
171 | 184 | | |
172 | 185 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | 189 | | |
181 | | - | |
182 | | - | |
| 190 | + | |
183 | 191 | | |
184 | 192 | | |
| 193 | + | |
185 | 194 | | |
186 | 195 | | |
187 | | - | |
| 196 | + | |
188 | 197 | | |
189 | 198 | | |
190 | 199 | | |
| |||
0 commit comments