bolt: [Bug] Failed to parse SVG image with text/html mime type

After updating Bolt to 3.2.9, the “Select from Server” function in the backend does not work anymore, the dialog shows a spinning dotted disk and then fails with a reload symbol. This is likely to be a config specific error and not a general Bolt 3.2.9 error since other people (running 3.2.9) dont experience this behaviour. The same error occurs on the local staging server running php 5.6 / nginx and the “production” server running apache. i doublechecked file permissions and file / dir ownerships on both machines. As in the other referenced issue, “Upload File” and “Select from Stack” still works fine.

Details

  • Bolt 3.2.9
  • Composer Install
  • PHP version: [ 5.6 & 7.0 ]
  • Used web server: [ Apache & Nginx ] nginx 1.11
  • All Browsers

Browser Console error: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Bolt system log

47	Critical	exception	asyncbrowse	An exception has been thrown during the rendering of a template ("Failed to get image data from file") in "@bolt/async/browse.twig" at line 123. 
URI: /async/browse/files?multiselect=true
Source: /xyz.de/vendor/twig/twig/lib/Twig/Template.php :: 447 

Nginx Error Log:

*13 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/1/00/0000000001 while reading upstream, client: 192.168.1.200, server: xyz.de, request: "GET /async/browse/files?multiselect=true HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: xyz.de", referrer: "https://xyz.de/bolt/editcontent/projects/1"

probably unrelated since the same error happens with nginx and apache: http://serverfault.com/questions/587386/an-upstream-response-is-buffered-to-a-temporary-file

maybe related but unlike in this issue, a different php version didnt solve the issue (tried on Apache with php 5.6 & php 7 - and on nginx with php 5.6) https://github.com/bolt/bolt/issues/4745

Still could be a rewrite issue, but the servers are using unmodified versions of the Nginx config example and the .htaccess file from the bolt distribution - so no idea how to fix this.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 24 (19 by maintainers)

Most upvoted comments

@cdowdy didn’t know GitHub supported collapsible blocks, thanks for that 😉

finfo still doesn’t work and since we you all are using bolt’s version of flysystem this wont work you’ll get null or text/plain using finfo

Flysystem uses Finfo.

flysystem needs the <?xml version="1.0" encoding="utf-8"?> block in the head…

Yes, that fixes the detection for the “bad” svg image.

Maybe we could do something like this:

$type = Flysystem\Util::guessMimeType($file, $data);
if ($type === 'text/html' && strpos($data, '<svg') === 0) {
    $data = '<?xml version="1.0" encoding="utf-8"?>' . $data;
    $type = Flysystem\Util::guessMimeType($file, $data);
}