Borrow buffer from imagedata pool when sanitizing SVG

This commit is contained in:
DarthSim
2022-10-15 19:31:04 +06:00
parent f95f57bb4d
commit f5f4fb6487
4 changed files with 27 additions and 12 deletions

View File

@@ -344,17 +344,14 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
// Don't process SVG
if originData.Type == imagetype.SVG {
if config.SanitizeSvg {
sanitized, svgErr := svg.Satitize(originData.Data)
sanitized, svgErr := svg.Satitize(originData)
checkErr(ctx, "svg_processing", svgErr)
// Since we'll replace origin data, it's better to close it to return
// it's buffer to the pool
originData.Close()
originData = &imagedata.ImageData{
Data: sanitized,
Type: imagetype.SVG,
}
originData = sanitized
}
respondWithImage(reqID, r, rw, statusCode, originData, po, imageURL, originData)