dompdf / php-svg-lib

SVG file parsing / rendering library
GNU Lesser General Public License v3.0
1.39k stars 77 forks source link

ErrorException: Undefined property: Svg\Style::$href #114

Closed rhorbas closed 5 months ago

rhorbas commented 5 months ago

I have an SVG image embedded in a PDF, which now throws an exception after updating to PHP 8.3 and Laravel 10.

File: src/Svg/Style.php: 146

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"]);
}

(After commenting out this block, the PDF is working again.)

bsweeney commented 5 months ago

I was just reviewing this code yesterday and realized that it's ... not correct. Working on a fix and should have it out soon.

pereira-pedro commented 5 months ago

Hello,

Is safe to remove this (src/Svg/Style.php:146) until a fix is published?

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($styles["font-family"]); }

bsweeney commented 5 months ago

I just added the change to master branch. If you have a moment to test and it looks good I'll go ahead and publish the next release.

pereira-pedro commented 5 months ago

I'm sorry but found another issue:

Message: 'Undefined variable $from', Trace: '#0 /app/sources/vendor/phenx/php-svg-lib/src/Svg/Tag/Image.php(61):

bsweeney commented 5 months ago

Don't be sorry. I'm the one who should be sorry, that was just sloppy. Should be fixed now.

pereira-pedro commented 5 months ago

I'm sorry because you're the one who is volunteering to do this work. I'm just a consumer. :D

Anyways. It works!

Thank you!