]> git.wh0rd.org - tt-rss.git/commitdiff
send_local_file: add application/octet-stream hack
authorAndrew Dolgov <noreply@fakecake.org>
Thu, 16 Aug 2018 09:16:51 +0000 (12:16 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Thu, 16 Aug 2018 09:16:51 +0000 (12:16 +0300)
cached_url: return original requested filename to save as

classes/handler/public.php [changed mode: 0644->0755]
include/functions.php

old mode 100644 (file)
new mode 100755 (executable)
index 8440bc3..e892a97
@@ -934,17 +934,17 @@ class Handler_Public extends Handler {
        }
 
        function cached_url() {
-               @$hash = basename($_GET['hash']);
+               @$req_filename = basename($_GET['hash']);
 
                // we don't need an extension to find the file, hash is a complete URL
-               $hash = preg_replace("/\.[^\.]*$/", "", $hash);
+               $hash = preg_replace("/\.[^\.]*$/", "", $req_filename);
 
                if ($hash) {
 
                        $filename = CACHE_DIR . '/images/' . $hash;
 
                        if (file_exists($filename)) {
-                               header("Content-Disposition: inline; filename=\"$hash\"");
+                               header("Content-Disposition: inline; filename=\"$req_filename\"");
 
                                send_local_file($filename);
 
index 7ebbe38b38b447137fad23c2cce88290e851b04f..b6e49716cd88ee710ede90a9fb835fb996f35761 100755 (executable)
                        }
 
                        $mimetype = mime_content_type($filename);
+
+                       // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4
+                       // video files are detected as octet-stream by mime_content_type()
+
+                       if ($mimetype == "application/octet-stream")
+                               $mimetype = "video/mp4";
+
                        header("Content-type: $mimetype");
 
                        $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT";