Skip to content

Commit

Permalink
very small change to getdomdocuments across the services
Browse files Browse the repository at this point in the history
  • Loading branch information
panbed committed Nov 20, 2024
1 parent c2be872 commit b4c4249
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Services/EqualAccessService.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getDomDocument($html)
// TODO: checks for if <html>, <body>, or <head> and <style> exist? technically canvas will always remove them if they are present in the HTML editor
// but you never know, also the loadHTML string is pretty long and kinda unreadable, could individually load in each element maybe
$dom = new DOMDocument('1.0', 'utf-8');
libxml_use_internal_errors(true);
libxml_use_internal_errors(true); // this might not be the best idea, we use this to stop udoit from crashing when it sees an html5 element

// Set the default background color and text color in the DOMDocument's <style>
$envBackgroundColor = $_ENV['BACKGROUND_COLOR'];
Expand Down
5 changes: 3 additions & 2 deletions src/Services/LocalApiAccessibilityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public function getDomDocument($html)
$dom = new DOMDocument('1.0', 'utf-8');
libxml_use_internal_errors(true);
if (strpos($html, '<?xml encoding="utf-8"') !== false) {
$dom->loadHTML("<html><body>{$html}</body></html>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$dom->loadHTML("<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Placeholder Page Title</title></head><body><div role=\"main\"><h1>Placeholder Page Title</h1>{$html}</div></body></html>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);

} else {
$dom->loadHTML("<?xml encoding=\"utf-8\" ?><html><body>{$html}</body></html>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$dom->loadHTML("<?xml encoding=\"utf-8\" ?><!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Placeholder Page Title</title></head><body><div role=\"main\"><h1>Placeholder Page Title</h1>{$html}</div></body></html>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
}

return $dom;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/ScannerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function scanContentItem(ContentItem $contentItem, $scannerReport = null,
else if ($scanner == 'equalaccess_lambda') {
if ($contentItem->getBody() != null) {
$equalAccess = new EqualAccessService();
$document = $equalAccess->getDomDocument($contentItem->getBody());
$document = $this->getDomDocument($contentItem->getBody());
if (!$scannerReport) {
// Report is null, we need to call the lambda function for a single page most likely
// $this->logToServer("null $scannerReport!");
Expand Down

0 comments on commit b4c4249

Please sign in to comment.