Skip to content
Snippets Groups Projects
Commit 9c728409 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fixed error on a tags with download attribute

parent 6280cb20
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
namespace App;
use DomDocument;
use DOMElement;
class HtmlDocument extends Document
{
......@@ -35,7 +36,6 @@ class HtmlDocument extends Document
if ($encoding !== null) {
break;
}
}
# If there is a Charset Meta Tag
if ($meta->hasAttribute("charset")) {
......@@ -93,6 +93,7 @@ class HtmlDocument extends Document
}
# First things first. Let's change all a Tags that can define a target Attribute
/** @var DOMElement */
foreach ($dom->getElementsByTagName('a') as $link) {
if ($link->hasAttribute("href")) {
if (stripos($link->getAttribute("href"), "#") === 0) {
......@@ -109,7 +110,11 @@ class HtmlDocument extends Document
$link->setAttribute("href", $this->proxifyUrl($link->getAttribute("href"), true));
}
}
# A tags might have a download attribute defined. Downloads are handled by the proxy
# In another way so we need to remove those attributes if present
if ($link->hasAttribute("download")) {
$link->removeAttribute("download");
}
}
# All Buttons
......@@ -137,7 +142,6 @@ class HtmlDocument extends Document
# And replace
$button->setAttribute("href", $href);
}
}
foreach ($dom->getElementsByTagName('area') as $area) {
......@@ -278,7 +282,6 @@ class HtmlDocument extends Document
$img->setAttribute("src", $this->convertRelativeToAbsoluteLink($img->getAttribute("src")));
# Convert all Image Sources to proxified Versions
$img->setAttribute("src", $this->proxifyUrl($img->getAttribute("src"), false));
}
# Some Images might contain a srcset (Different Images for different resolutions)
# Syntax would be i.e. srcset="medium.jpg 1000w, large.jpg 2000w"
......@@ -397,12 +400,11 @@ class HtmlDocument extends Document
libxml_use_internal_errors(false);
}
/**
* This function changes the current Target Attribute on the link to given new target Attribute
*/
/**
* This function changes the current Target Attribute on the link to given new target Attribute
*/
private function convertTargetAttribute($link, $newTarget)
{
$link->setAttribute("target", $newTarget);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment