emogrifier: False positives for content-type meta element presence check
I’ve recently updated Emogrifier and when moving from the old style syntax to the new, I receive this error:
PHP Fatal error: Uncaught TypeError: Return value of Pelago\Emogrifier\CssInliner::getHeadElement() must be an instance of DOMElement, null returned in /var/www/vhosts/test.system/httpdocs/vendor/pelago/emogrifier/src/CssInliner.php:1293
Is there a reason there must always be a <head>
element?
https://github.com/MyIntervals/emogrifier/blob/b43b650880d189b0ada61d95d0729c7424b1752d/src/CssInliner.php#L1291
I’m just inlining CSS in a simple email template that doesn’t use a <head>
element for anything.
I’ve added a blank one for now but strikes me as a little arbitrary.
Thanks!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- [BUGFIX] Allow "Content-Type" in content Use a regular expression to determine whether the provided HTML contains a `Content-Type` `meta` element instead of just testing for the string "Content-Type"... — committed to MyIntervals/emogrifier by JakeQZ 3 years ago
- [BUGFIX] Allow "Content-Type" in content Use a regular expression to determine whether the provided HTML contains a `Content-Type` `meta` element instead of just testing for the string "Content-Type"... — committed to MyIntervals/emogrifier by JakeQZ 3 years ago
- [BUGFIX] Allow "Content-Type" in content (#959) Use a regular expression to determine whether the provided HTML contains a `Content-Type` `meta` element instead of just testing for the string "Cont... — committed to MyIntervals/emogrifier by JakeQZ 3 years ago
@JakeQZ I’ve hit this error again and can replicate it with this HTML - https://gist.github.com/bbeckford/eea6c7a1a8a4957166050dda413a9af1
Code to reproduce:
This produces the following error:
Version info from composer.lock: (running PHP v7.3.27)
Hey thanks for the fix @JakeQZ 😃
@bbeckford Thanks! We’ll have a look at the problem.
Hi @oliverklee included html is here - https://gist.github.com/bbeckford/eea6c7a1a8a4957166050dda413a9af1
I haven’t included the CSS at this stage as I’d have to comb through it to make sure it was ok for public consumption, let me see if I can reproduce with something simpler…
Hi @JakeQZ - sorry for the delay.
Strange, I can’t seem to replicate this now! The dev environment I was testing on has moved on now so there’s no way for me to know for sure but perhaps I was using an older version at the time,
Now definitely using emogrifier v5.0.0 and the snippet above does work.
I’ve removed this line from the code I was working on and I will let you know if this ever reoccurs on any of my instances:
Thanks for your help!