foreach ($words as $index => $word) {
$openIsolatedDiffTag = $this->isOpeningIsolatedDiffTag($word, $currentIsolatedDiffTag);
if ($openIsolatedDiffTag) {
- if ($this->isSelfClosingTag($word) || stripos($word, '<img') !== false) {
+ if ($this->isSelfClosingTag($word) || mb_stripos($word, '<img') !== false) {
if ($openIsolatedDiffTags === 0) {
$isolatedDiffTagIndices[] = array(
'start' => $index,
$tagsToMatch = $currentIsolatedDiffTag !== null
? array($currentIsolatedDiffTag => $this->config->getIsolatedDiffTagPlaceholder($currentIsolatedDiffTag))
: $this->config->getIsolatedDiffTags();
- $pattern = '#<%s(\s+[^>]*)?>#iU';
+ $pattern = '#<%s(\s+[^>]*)?>#iUu';
foreach ($tagsToMatch as $key => $value) {
if (preg_match(sprintf($pattern, $key), $item)) {
return $key;
protected function isSelfClosingTag($text)
{
- return (bool) preg_match('/<[^>]+\/\s*>/', $text);
+ return (bool) preg_match('/<[^>]+\/\s*>/u', $text);
}
/**
$tagsToMatch = $currentIsolatedDiffTag !== null
? array($currentIsolatedDiffTag => $this->config->getIsolatedDiffTagPlaceholder($currentIsolatedDiffTag))
: $this->config->getIsolatedDiffTags();
- $pattern = '#</%s(\s+[^>]*)?>#iU';
+ $pattern = '#</%s(\s+[^>]*)?>#iUu';
foreach ($tagsToMatch as $key => $value) {
if (preg_match(sprintf($pattern, $key), $item)) {
return $key;
$wrapEnd = '';
if ($stripWrappingTags) {
- $pattern = '/(^<[^>]+>)|(<\/[^>]+>$)/i';
+ $pattern = '/(^<[^>]+>)|(<\/[^>]+>$)/iu';
$matches = array();
if (preg_match_all($pattern, $newText, $matches)) {
protected function getAttributeFromTag($text, $attribute)
{
$matches = array();
- if (preg_match(sprintf('/<[^>]*\b%s\s*=\s*([\'"])(.*)\1[^>]*>/i', $attribute), $text, $matches)) {
+ if (preg_match(sprintf('/<[^>]*\b%s\s*=\s*([\'"])(.*)\1[^>]*>/iu', $attribute), $text, $matches)) {
return htmlspecialchars_decode($matches[2]);
}
}
}
}
- if (count($words) == 0 && count($specialCaseTagInjection) == 0) {
+ if (count($words) == 0 && mb_strlen($specialCaseTagInjection) == 0) {
break;
}
if ($specialCaseTagInjectionIsBefore) {
} else {
$workTag = $this->extractConsecutiveWords($words, 'tag');
if (isset($workTag[ 0 ]) && $this->isOpeningTag($workTag[ 0 ]) && !$this->isClosingTag($workTag[ 0 ])) {
- if (strpos($workTag[ 0 ], 'class=')) {
+ if (mb_strpos($workTag[ 0 ], 'class=')) {
$workTag[ 0 ] = str_replace('class="', 'class="diffmod ', $workTag[ 0 ]);
$workTag[ 0 ] = str_replace("class='", 'class="diffmod ', $workTag[ 0 ]);
} else {
}
$appendContent = implode('', $workTag).$specialCaseTagInjection;
- if (isset($workTag[0]) && false !== stripos($workTag[0], '<img')) {
+ if (isset($workTag[0]) && false !== mb_stripos($workTag[0], '<img')) {
$appendContent = $this->wrapText($appendContent, $tag, $cssClass);
}
$this->content .= $appendContent;
*/
protected function isOpeningTag($item)
{
- return preg_match('#<[^>]+>\\s*#iU', $item);
+ return preg_match('#<[^>]+>\\s*#iUu', $item);
}
/**
*/
protected function isClosingTag($item)
{
- return preg_match('#</[^>]+>\\s*#iU', $item);
+ return preg_match('#</[^>]+>\\s*#iUu', $item);
}
/**
*/
protected function stripTagAttributes($word)
{
- $space = strpos($word, ' ', 1);
+ $space = mb_strpos($word, ' ', 1);
if ($space) {
- return '<' . substr($word, 1, $space) . '>';
+ return '<' . mb_substr($word, 1, $space) . '>';
}
return trim($word, '<>');
protected function isOnlyWhitespace($str)
{
// Slightly faster then using preg_match
- return $str !== '' && (strlen(trim($str)) === 0);
+ return $str !== '' && (mb_strlen(trim($str)) === 0);
}
/**