Skip to content
Snippets Groups Projects
Verified Commit 34dc1a80 authored by William Desportes's avatar William Desportes :sailboat:
Browse files

New upstream version 0.5.1

parents 68bbad60 8a8a1ebc
No related branches found
No related tags found
No related merge requests found
# Security Policy
## Supported Versions
Because of limited resources and general compatibility
between versions only the [latest release](https://github.com/dompdf/php-svg-lib/releases) of Dompdf
is actively supported.
## Reporting a Vulnerability
In order to give the community time to respond and patch
we strongly urge you report all security issues privately.
New vulnerabilities can be reported through the GitHub
[Security Advisories](https://github.com/dompdf/php-svg-lib/security/advisories)
feature. If you have any questions email us at security@dompdf.org and
we will respond ASAP.
......@@ -53,6 +53,8 @@ class Document extends AbstractTag
/** @var \Sabberworm\CSS\CSSList\Document[] */
protected $styleSheets = array();
public $allowExternalReferences = true;
public function loadFile($filename)
{
$this->filename = $filename;
......
......@@ -139,6 +139,16 @@ class Style
break;
}
}
if (
\array_key_exists("font-family", $styles)
&& (
\strtolower(\substr($this->href, 0, 7)) === "phar://"
|| ($this->document->allowExternalReferences === false && \strtolower(\substr($this->href, 0, 5)) !== "data:")
)
) {
unset($style["font-family"]);
}
}
}
......
......@@ -58,6 +58,10 @@ class Image extends AbstractTag
$this->document->getSurface()->transform(1, 0, 0, -1, 0, $height);
if (\strtolower(\substr($this->href, 0, 7)) === "phar://" || ($this->document->allowExternalReferences === false && \strtolower(\substr($this->href, 0, 5) !== "data:"))) {
return;
}
$this->document->getSurface()->drawImage($this->href, $this->x, $this->y, $this->width, $this->height);
}
......
......@@ -14,12 +14,19 @@ class UseTag extends AbstractTag
protected $y = 0;
protected $width;
protected $height;
protected $instances = 0;
/** @var AbstractTag */
protected $reference;
protected function before($attributes)
{
$this->instances++;
if ($this->instances > 1) {
//TODO: log circular reference error state
return;
}
if (isset($attributes['x'])) {
$this->x = $attributes['x'];
}
......@@ -52,6 +59,9 @@ class UseTag extends AbstractTag
}
protected function after() {
if ($this->instances > 0) {
return;
}
parent::after();
if ($this->reference) {
......@@ -63,6 +73,11 @@ class UseTag extends AbstractTag
public function handle($attributes)
{
if ($this->instances > 1) {
//TODO: log circular reference error state
return;
}
parent::handle($attributes);
if (!$this->reference) {
......@@ -70,7 +85,7 @@ class UseTag extends AbstractTag
}
$mergedAttributes = $this->reference->attributes;
$attributesToNotMerge = ['x', 'y', 'width', 'height'];
$attributesToNotMerge = ['x', 'y', 'width', 'height', 'href', 'xlink:href', 'id'];
foreach ($attributes as $attrKey => $attrVal) {
if (!in_array($attrKey, $attributesToNotMerge) && !isset($mergedAttributes[$attrKey])) {
$mergedAttributes[$attrKey] = $attrVal;
......@@ -87,6 +102,11 @@ class UseTag extends AbstractTag
public function handleEnd()
{
$this->instances--;
if ($this->instances > 0) {
return;
}
parent::handleEnd();
if (!$this->reference) {
......
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