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

Change-Id: I55b9521dd195bf9c2eec378529ff0cde90db8769
Fixes: #32278
Releases: 6.1, 6.0, 4.7, 4.6, 4.5
Reviewed-on: https://review.typo3.org/16979
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Falk K├╝hnel
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 1213545..6dd0450 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>';
@@ -4754,4 +4761,4 @@ if (version == "n3") {
 }
 
 
-?>
\ No newline at end of file
+?>