Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions libraries/joomla/filter/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,10 @@ protected function cleanTags($source)
// Find position of equal and open quotes ignoring
if (preg_match('#\s*=\s*\"#', $fromSpace, $matches, PREG_OFFSET_CAPTURE))
{
// We have found an attribute, convert its byte position to a UTF-8 string length, using non-multibyte substr()
$stringBeforeAttr = substr($fromSpace, 0, $matches[0][1]);
$startAttPosition = StringHelper::strlen($stringBeforeAttr);
$startAtt = $matches[0][0];
$startAttPosition = $matches[0][1];
$closeQuotes = StringHelper::strpos(
StringHelper::substr($fromSpace, ($startAttPosition + StringHelper::strlen($startAtt))), '"'
) + $startAttPosition + StringHelper::strlen($startAtt);
Expand Down Expand Up @@ -1080,8 +1082,11 @@ protected function escapeAttributeValues($source)
*/
while (preg_match('#<[^>]*?=\s*?(\"|\')#s', $remainder, $matches, PREG_OFFSET_CAPTURE))
{
// We have found an opening quote, convert its byte position to a UTF-8 string length, using non-multibyte substr()
$stringBeforeQuote = substr($remainder, 0, $matches[1][1]);
$quotePosition = StringHelper::strlen($stringBeforeQuote);

// Get the portion before the attribute value
$quotePosition = $matches[0][1];
$nextBefore = $quotePosition + StringHelper::strlen($matches[0][0]);

/*
Expand All @@ -1092,9 +1097,12 @@ protected function escapeAttributeValues($source)
$pregMatch = ($quote == '"') ? '#(\"\s*/\s*>|\"\s*>|\"\s+|\"$)#' : "#(\'\s*/\s*>|\'\s*>|\'\s+|\'$)#";

// Get the portion after attribute value
if (preg_match($pregMatch, StringHelper::substr($remainder, $nextBefore), $matches, PREG_OFFSET_CAPTURE))
$attributeValueRemainder = StringHelper::substr($remainder, $nextBefore);
if (preg_match($pregMatch, $attributeValueRemainder, $matches, PREG_OFFSET_CAPTURE))
{
// We have a closing quote
// We have a closing quote, convert its byte position to a UTF-8 string length, using non-multibyte substr()
$stringBeforeQuote = substr($attributeValueToEnd, 0, $matches[0][1]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$attributeValueToEnd is undefined.... did you mean $attributeValueRemainder?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i meant $attributeValueRemainder, i marginally got some time to make the PR before getting some very much needed sleep, lol

$closeQuoteChars = StringHelper::strlen($stringBeforeQuote);
$nextAfter = $nextBefore + $matches[0][1];
}
else
Expand Down