[BUGFIX] INTincScript_loadJSCode() causes PHP warnings
authorMarkus Klein <klein.t3@mfc-linz.at>
Mon, 19 Dec 2011 13:34:32 +0000 (14:34 +0100)
committerDmitry Dulepov <dmitry@typo3.org>
Thu, 6 Dec 2012 10:07:42 +0000 (11:07 +0100)
This function uses implode() on several variables without properly
checking if they are actually arrays.
This might cause PHP warnings.

Change-Id: I83d2de074a49f1d724f95ee0def6b3c8a170317e
Fixes: #32278
Releases: 6.1, 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7042
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 9a1a63c..093faf1 100644 (file)
@@ -3477,42 +3477,49 @@ class TypoScriptFrontendController {
         * Loads the JavaScript code for INTincScript
         *
         * @return void
-        * @access private
         * @todo Define visibility
         */
        public function INTincScript_loadJSCode() {
                // If any images added, then add them to the javascript section
-               if ($this->JSImgCode) {
+               $jsImgCode = trim($this->JSImgCode);
+               if ($jsImgCode !== '') {
                        $this->additionalHeaderData['JSImgCode'] = '
 <script type="text/javascript">
        /*<![CDATA[*/
 <!--
 if (version == "n3") {
-' . trim($this->JSImgCode) . '
+' . $jsImgCode . '
 }
 // -->
        /*]]>*/
 </script>';
                }
                // Add javascript
-               if ($this->JSCode || count($this->additionalJavaScript)) {
+               $jsCode = trim($this->JSCode);
+               $additionalJavaScript = is_array($this->additionalJavaScript)
+                       ? implode(LF, $this->additionalJavaScript)
+                       : $this->additionalJavaScript;
+               $additionalJavaScript = trim($additionalJavaScript);
+               if ($jsCode !== '' || $additionalJavaScript !== '') {
                        $this->additionalHeaderData['JSCode'] = '
 <script type="text/javascript">
        /*<![CDATA[*/
 <!--
-' . implode(LF, $this->additionalJavaScript) . '
-' . trim($this->JSCode) . '
+' . $additionalJavaScript . '
+' . $jsCode . '
 // -->
        /*]]>*/
 </script>';
                }
-               // Add javascript
-               if (count($this->additionalCSS)) {
+               // Add CSS
+               $additionalCss = is_array($this->additionalCSS) ? implode(LF, $this->additionalCSS) : $this->additionalCSS;
+               $additionalCss = trim($additionalCss);
+               if ($additionalCss !== '') {
                        $this->additionalHeaderData['_CSS'] = '
 <style type="text/css">
        /*<![CDATA[*/
 <!--
-' . implode(LF, $this->additionalCSS) . '
+' . $additionalCss . '
 // -->
        /*]]>*/
 </style>';