[BUGFIX] INTincScript_loadJSCode() causes PHP warnings 86/16986/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:59:43 +0000 (09:59 +0100)
This function uses implode() on several variables without properly
checking if they are actually arrays.
This might cause PHP warnings.

Change-Id: If5ce7b985eeee3f7fd8016314a191c10e2c05414
Fixes: #32278
Releases: 6.1, 6.0, 4.7, 4.6, 4.5
Reviewed-on: https://review.typo3.org/16986
Reviewed-by: Falk K├╝hnel
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
typo3/sysext/cms/tslib/class.tslib_fe.php

index 94bb3b5..ea3d024 100644 (file)
         * @access private
         */
        function INTincScript_loadJSCode()      {
-               if ($this->JSImgCode)   {       // If any images added, then add them to the javascript section
-                       $this->additionalHeaderData['JSImgCode']='
+               // If any images added, then add them to the javascript section
+               $jsImgCode = trim($this->JSImgCode);
+               if ($jsImgCode !== '') {
+                       $this->additionalHeaderData['JSImgCode'] = '
 <script type="text/javascript">
        /*<![CDATA[*/
 <!--
 if (version == "n3") {
-'.trim($this->JSImgCode).'
+' . $jsImgCode . '
 }
 // -->
        /*]]>*/
 </script>';
                }
-               if ($this->JSCode || count($this->additionalJavaScript))        {       // Add javascript
-                       $this->additionalHeaderData['JSCode']='
+               // Add javascript
+               $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>';
                }
-               if (count($this->additionalCSS))        {       // Add javascript
-                       $this->additionalHeaderData['_CSS']='
+               // 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>';
@@ -4881,4 +4892,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']);
 }
 
-?>
\ No newline at end of file
+?>