Index: typo3/sysext/cms/tests/tslib/tslib_cObj_testcase.php =================================================================== --- typo3/sysext/cms/tests/tslib/tslib_cObj_testcase.php (revision 7378) +++ typo3/sysext/cms/tests/tslib/tslib_cObj_testcase.php (working copy) @@ -69,7 +69,7 @@ public function providerForCrop() { $plainText = 'Kasper Skårhøj implemented the original version of the crop function.'; $textWithMarkup = 'Kasper Skårhøj implemented the original version of the crop function.'; - $textWithEntities = 'Kasper Skårhøj implemented the original version of the crop function.'; + $textWithEntities = 'Kasper Skårhøj implemented the; original version of the crop function.'; $charsets = array(); $charsets[] = 'iso-8859-1'; @@ -104,9 +104,9 @@ $charset . ' text with entities 14|...' => array('14|...', $textWithEntities, 'Kasper Skårhøj...', $charset), $charset . ' text with entities 15|...' => array('15|...', $textWithEntities, 'Kasper Skårhøj ...', $charset), $charset . ' text with entities 16|...' => array('16|...', $textWithEntities, 'Kasper Skårhøj i...', $charset), - $charset . ' text with entities -56|...' => array('-56|...', $textWithEntities, '...j implemented the original version of the crop function.', $charset), - $charset . ' text with entities -57|...' => array('-57|...', $textWithEntities, '...øj implemented the original version of the crop function.', $charset), - $charset . ' text with entities -58|...' => array('-58|...', $textWithEntities, '...høj implemented the original version of the crop function.', $charset), + $charset . ' text with entities -56|...' => array('-57|...', $textWithEntities, '...j implemented the; original version of the crop function.', $charset), + $charset . ' text with entities -57|...' => array('-58|...', $textWithEntities, '...øj implemented the; original version of the crop function.', $charset), + $charset . ' text with entities -58|...' => array('-59|...', $textWithEntities, '...høj implemented the; original version of the crop function.', $charset), $charset . ' text with entities 9|...|1' => array('9|...|1', $textWithEntities, 'Kasper...', $charset), $charset . ' text with entities 10|...|1' => array('10|...|1', $textWithEntities, 'Kasper...', $charset), $charset . ' text with entities 11|...|1' => array('11|...|1', $textWithEntities, 'Kasper...', $charset), @@ -114,9 +114,9 @@ $charset . ' text with entities 14|...|1' => array('14|...|1', $textWithEntities, 'Kasper Skårhøj...', $charset), $charset . ' text with entities 15|...|1' => array('15|...|1', $textWithEntities, 'Kasper Skårhøj...', $charset), $charset . ' text with entities 16|...|1' => array('16|...|1', $textWithEntities, 'Kasper Skårhøj...', $charset), - $charset . ' text with entities -56|...|1' => array('-56|...|1', $textWithEntities, '...implemented the original version of the crop function.', $charset), - $charset . ' text with entities -57|...|1' => array('-57|...|1', $textWithEntities, '...implemented the original version of the crop function.', $charset), - $charset . ' text with entities -58|...|1' => array('-58|...|1', $textWithEntities, '...implemented the original version of the crop function.', $charset) + $charset . ' text with entities -56|...|1' => array('-57|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset), + $charset . ' text with entities -57|...|1' => array('-58|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset), + $charset . ' text with entities -58|...|1' => array('-59|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset) )); } return $data; Index: typo3/sysext/cms/tslib/class.tslib_content.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_content.php (revision 7378) +++ typo3/sysext/cms/tslib/class.tslib_content.php (working copy) @@ -4308,11 +4308,16 @@ if (($strLen + $thisStrLen > $absChars)) { $croppedOffset = $offset; $cropPosition = $absChars - $strLen; + // The snippet "&[^&\s;]{2,8};" in the RegEx below represents entities. + $patternMatchEntityAsSingleChar = '(&[^&\s;]{2,8};|.)'; if ($crop2space) { - $cropRegEx = $chars < 0 ? '#(?<=\s)(.(?![^&\s]{2,7};)|(&[^&\s;]{2,7};)){0,' . $cropPosition . '}$#ui' : '#^(.(?![^&\s]{2,7};)|(&[^&\s;]{2,7};)){0,' . $cropPosition . '}(?=\s)#ui'; + $cropRegEx = $chars < 0 ? + '#(?<=\s)' . $patternMatchEntityAsSingleChar . '{0,' . $cropPosition . '}$#ui' : + '#^' . $patternMatchEntityAsSingleChar . '{0,' . $cropPosition . '}(?=\s)#ui'; } else { - // The snippets "&[^&\s;]{2,7};" in the RegEx below represents entities. - $cropRegEx = $chars < 0 ? '#(.(?![^&\s]{2,7};)|(&[^&\s;]{2,7};)){0,' . $cropPosition . '}$#ui' : '#^(.(?![^&\s]{2,7};)|(&[^&\s;]{2,7};)){0,' . $cropPosition . '}#ui'; + $cropRegEx = $chars < 0 ? + '#' . $patternMatchEntityAsSingleChar . '{0,' . $cropPosition . '}$#ui' : + '#^' . $patternMatchEntityAsSingleChar . '{0,' . $cropPosition . '}#ui'; } if (preg_match($cropRegEx, $tempContent, $croppedMatch)) { $tempContent = $croppedMatch[0];