From 7a71cdc21cd33f8f5cf879d28288ce06e63e0956 Mon Sep 17 00:00:00 2001
From: Thoams Oliver Moll <tom@fullcircle.de>
Date: Fri, 13 Jan 2017 15:05:50 +0100
Subject: [PATCH] [BUGFIX] Truncate long GIFBUILDER file names

GIFBUILDER generates file names from serialized data from
the GIFBUILDER setup (typoscript).
This can result in too long file names when the GIFBUILDER
is called with many parameters and on filesystems with
a max filename/path length.

The comment of the function fileName() states that the filename
should be shortened to 100 chars, but this doesn't happen.

This patch introduces a simple substring to enforce this limit.

Change-Id: Iaa17760bbf34fc6c01a9bc5ea8d1f8b6b242fecb
Resolves: #79301
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/51305
Reviewed-by: Marco Huber <mail@marco-huber.de>
Tested-by: Marco Huber <mail@marco-huber.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
---
 typo3/sysext/frontend/Classes/Imaging/GifBuilder.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php b/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
index 9f91fa46674f..82ef0445dd8c 100644
--- a/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
+++ b/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
@@ -704,6 +704,9 @@ class GifBuilder extends GraphicalFunctions
         $filePrefix = implode('_', array_merge($this->combinedTextStrings, $this->combinedFileNames));
         $filePrefix = $basicFileFunctions->cleanFileName($filePrefix);
 
+        // shorten prefix to avoid overly long file names
+        $filePrefix = substr($filePrefix, 0, 100);
+
         return $this->tempPath . $pre . $filePrefix . '_' . GeneralUtility::shortMD5(serialize($this->setup)) . '.' . $this->extension();
     }
 
-- 
GitLab