Fix bug #4678: t3lib_div::array2xml() may crash with PHP 5.2.0
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Tue, 30 Jan 2007 20:19:53 +0000 (20:19 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Tue, 30 Jan 2007 20:19:53 +0000 (20:19 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1960 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php

index 22cfa93..d887a68 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 2007-01-30  Martin Kutschker  <martin.t.kutschker@blackbox.net>
 
        * Fixing oddities in recursive stdWraps (bugs #4312 and #4871)
+       * Fix bug #4678: t3lib_div::array2xml() may crash with PHP 5.2.0
 
 2007-01-30  Dmitry Dulepov  <dmitry@typo3.org>
 
index e64d8b5..874929d 100755 (executable)
@@ -2079,7 +2079,8 @@ class t3lib_div {
                                } else {        // Just a value:
 
                                                // Look for binary chars:
-                                       if (strcspn($v,$binaryChars) != strlen($v))     {       // Go for base64 encoding if the initial segment NOT matching any binary char has the same length as the whole string!
+                                       $vLen = strlen($v);     // check for length, because PHP 5.2.0 may crash when first argument of strcspn is empty
+                                       if ($vLen && strcspn($v,$binaryChars) != $vLen) {       // Go for base64 encoding if the initial segment NOT matching any binary char has the same length as the whole string!
                                                        // If the value contained binary chars then we base64-encode it an set an attribute to notify this situation:
                                                $content = $nl.chunk_split(base64_encode($v));
                                                $attr.=' base64="1"';