checkAltStaysInside renders the image this asset will produce and parses it back, so alt text that escapeAlt failed to neutralize is refused before the upload rather than discovered after it. An upload cannot be undone, which is why the check runs at validation. The URL is a stand-in, since the rea
(a *imageAsset)
| 207 | // The URL is a stand-in, since the real one does not exist until the asset has |
| 208 | // uploaded. Only the alt text varies, so a stand-in proves the same thing. |
| 209 | func checkAltStaysInside(a *imageAsset) error { |
| 210 | const probeURL = "https://example.invalid/probe" |
| 211 | if !isSingleImage(a.markdown(probeURL), probeURL) { |
| 212 | return fmt.Errorf("%s: alt text cannot be rendered safely", a.path) |
| 213 | } |
| 214 | return nil |
| 215 | } |
no test coverage detected