You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The maybeGetInfo function is called by the uploadBlob implementation in the PDS and tries to get image information (eg height, width, format) from the upload contents using the sharp library. There's a corner case here though: if the code can't recognize the contents as an image then this function returns null to indicate it isn't an image, but if the sharp library decides that the blob contains an image and fails while decoding it then an exception is thrown. This sharp library exception propagates up and causes a 500 error to be returned to the PDS client.
In the case in this ticket, the text "<svg" is enough for sharp to decide the image is an SVG file (internally it uses ImageMagick which defines the following patterns for SVG files), but then it fails to decode the rest of the image as it expects the contents to be valid XML. The actual exception thrown from sharp is:
Input buffer has corrupt header: glib: XML parse error: Error domain 1 code 73 on line 1 column 6 of data: Couldn't find end of Start Tag svgQ line 1
Given that maybeGetInfo is only used to detect image information, and the fact that it allows through some set of corrupt images (those that don't match any ImageMagick patterns), maybe its reasonable to just catch all exceptions from sharp and return null here too? Alternatively could turn this into an exception that causes a proper HTTP status code (e.g. 400) to be returned to the client?
Describe the bug
com.atproto.repo.uploadBlob fails with a payload containing "<svg" followed by any other characters, with a mimeType of "text/html".
To Reproduce
Steps to reproduce the behavior:
500: Internal Server Error
.Expected behavior
The blob successfully uploads.
Additional context
The text was updated successfully, but these errors were encountered: