From e02ab9ae422fdfa4039411712759fb66c71df12f Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 9 Jan 2015 11:44:57 -0600
Subject: [PATCH] oops: Fix download of files with no signature

Files upgraded from versions of osTicket prior to 1.9.1 did not have a
`signature` field in the database. For caching purposes in generating the
Etag HTTP header, the getSignature function cascades through the getKey
method. This may be inconsistent in the signed URL creation.

This patch adds a cascade flag to the getSignature method so the cascading
will not happen unless specifically requested.
---
 include/class.file.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/class.file.php b/include/class.file.php
index 21c9bff4a..b9210fcce 100644
--- a/include/class.file.php
+++ b/include/class.file.php
@@ -97,9 +97,9 @@ class AttachmentFile {
         return $this->ht['key'];
     }
 
-    function getSignature() {
+    function getSignature($cascade=false) {
         $sig = $this->ht['signature'];
-        if (!$sig) return $this->getKey();
+        if (!$sig && $cascade) return $this->getKey();
         return $sig;
     }
 
@@ -153,7 +153,7 @@ class AttachmentFile {
     }
 
     function makeCacheable($ttl=86400) {
-        Http::cacheable($this->getSignature(), $this->lastModified(), $ttl);
+        Http::cacheable($this->getSignature(true), $this->lastModified(), $ttl);
     }
 
     function display($scale=false) {
-- 
GitLab