package modules import ( "bytes" "path" "strings" ) // maxPreviewSize bounds how large an image the blob view will render inline. // Past it the view keeps the download link but drops the preview, so a large // file is not pulled over the wire twice (once as the page's subresource, // once as the bytes the reader actually wanted). The /raw/ route itself is // not capped here: a direct request is an explicit request for the bytes, // and MaxGit still bounds every git read. const maxPreviewSize = 2 << 20 // 2 MiB // imageContentType returns the MIME type to serve at p when its leading // bytes are that format and the extension agrees, and "" otherwise. // // SECURITY: this is the one place /raw/ is allowed to declare a non-text // Content-Type, so the rules are deliberately narrow: // - only raster formats are recognised. SVG is an XML document that can // carry