Project

General

Profile

Bug #22357 » issue_13972_v4.diff

Administrator Admin, 2010-04-16 23:32

View differences:

typo3/sysext/cms/tests/tslib/tslib_cObj_testcase.php (working copy)
public function providerForCrop() {
$plainText = 'Kasper Sk?rh?j implemented the original version of the crop function.';
$textWithMarkup = '<strong><a href="mailto:kasper@typo3.org">Kasper Sk?rh?j</a> implemented</strong> the original version of the crop function.';
$textWithEntities = 'Kasper Sk&aring;rh&oslash;j implemented the original version of the crop function.';
$textWithEntities = 'Kasper Sk&aring;rh&oslash;j implemented the; original version of the crop function.';
$charsets = array();
$charsets[] = 'iso-8859-1';
......
$charset . ' text with entities 14|...' => array('14|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset),
$charset . ' text with entities 15|...' => array('15|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j ...', $charset),
$charset . ' text with entities 16|...' => array('16|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;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, '...&oslash;j implemented the original version of the crop function.', $charset),
$charset . ' text with entities -58|...' => array('-58|...', $textWithEntities, '...h&oslash;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, '...&oslash;j implemented the; original version of the crop function.', $charset),
$charset . ' text with entities -58|...' => array('-59|...', $textWithEntities, '...h&oslash;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),
......
$charset . ' text with entities 14|...|1' => array('14|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset),
$charset . ' text with entities 15|...|1' => array('15|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset),
$charset . ' text with entities 16|...|1' => array('16|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;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;
typo3/sysext/cms/tslib/class.tslib_content.php (working copy)
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];
(4-4/4)