Skip to content

Commit

Permalink
use ENT_COMPAT, which was default up to PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll committed Jan 30, 2023
1 parent f6aff8d commit 27e064d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/PHPCodeBrowser/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected function getSource(): string
*/
protected function getDescription(DOMElement $element): string
{
return \htmlentities($element->getAttribute($this->descriptionAttr));
return \htmlentities($element->getAttribute($this->descriptionAttr), ENT_COMPAT);
}

/**
Expand All @@ -323,6 +323,6 @@ protected function getDescription(DOMElement $element): string
*/
protected function getSeverity(DOMElement $element): string
{
return \htmlentities($element->getAttribute($this->severityAttr));
return \htmlentities($element->getAttribute($this->severityAttr), ENT_COMPAT);
}
}
4 changes: 1 addition & 3 deletions src/PHPCodeBrowser/Plugins/ErrorCPD.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ public function mapIssues(DOMElement $element, string $filename): array
(int) $file->getAttribute('line'),
(int) $file->getAttribute('line') + $lineCount,
'Duplication',
\htmlentities(
$this->getCpdDescription($parentNode->childNodes, $file)
),
\htmlentities($this->getCpdDescription($parentNode->childNodes, $file), ENT_COMPAT),
'notice'
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PHPCodeBrowser/Plugins/ErrorPMD.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function getDescription(DOMElement $element): string
return \str_replace(
'
',
'',
\htmlentities($element->textContent)
\htmlentities($element->textContent, ENT_COMPAT)
);
}
}
6 changes: 3 additions & 3 deletions src/PHPCodeBrowser/View/ViewReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected function highlightPhpCode(string $sourceCode): DOMDocument
foreach ($sourceElements as $sourceElement) {
if ($sourceElement instanceof DOMText) {
$span = $targetDom->createElement('span');
$span->nodeValue = \htmlspecialchars($sourceElement->wholeText);
$span->nodeValue = \htmlspecialchars($sourceElement->wholeText, ENT_COMPAT);
$liElement->appendChild($span);
}

Expand Down Expand Up @@ -250,7 +250,7 @@ protected function highlightPhpCode(string $sourceCode): DOMDocument
} else {
// append content to current li element
$span = $targetDom->createElement('span');
$span->nodeValue = \htmlspecialchars($sourceChildElement->textContent);
$span->nodeValue = \htmlspecialchars($sourceChildElement->textContent, ENT_COMPAT);
$span->setAttribute('class', $elementClass);
$liElement->appendChild($span);
}
Expand Down Expand Up @@ -294,7 +294,7 @@ protected function highlightCode(string $file): DOMDocument
return $this->highlightPhpCode($sourceCode);
}

$sourceCode = \preg_replace(['/^.*$/m', '/ /'], ['<li>$0</li>', '&nbsp;'], \htmlentities($sourceCode));
$sourceCode = \preg_replace(['/^.*$/m', '/ /'], ['<li>$0</li>', '&nbsp;'], \htmlentities($sourceCode, ENT_COMPAT));
$sourceCode = '<div class="code"><ol class="code">'.$sourceCode.'</ol></div>';
$sourceCode = $this->stripInvalidXml($sourceCode);

Expand Down

0 comments on commit 27e064d

Please sign in to comment.