pentacent / keila

Open Source Newsletter Tool.
https://keila.io
GNU Affero General Public License v3.0
1.25k stars 61 forks source link

Embedding of (large?) images as data URLs breaks campaign rendering #218

Closed wmnnd closed 11 months ago

wmnnd commented 1 year ago

I just came across an email campaign that had a 1 MB+ image embedded as a data url. Trying to edit the campaign in Keila ultimately led to a timeout error. Trying to manually render the campaign with Keila.Mailings.Builder.build/2 also resulted in what appeared to be an infinite loop.

We should:

katafrakt commented 11 months ago

That was kind of fun to debug. I've been able to reproduce it with a 60K image - it takes about 40 seconds to render it on my machine. After that, I was able to narrow the culprit down to Earmark.as_html. However, I was left puzzled, because my quick reproduction script did not show the behaviour of very slow rendering.

So I pinned Earmark and Earmark Parser versions to the ones used by Keila and indeed - the slow rendering occurred. After some more playing around, I noticed that upgrading earmark_parser from 1.4.30 to 1.4.31 fixes the issue. I'm pretty sure this is related to https://github.com/RobertDober/earmark_parser/pull/125

After upgrading earmark_parser in Keila, I can no longer reproduce the issue with very slow rendering.

wmnnd commented 11 months ago

Thank you for finding this bug and for fixing it with a PR! Great work! :partying_face:

wmnnd commented 11 months ago

I’ve released Keila 0.12.5 including only your fix in the changelog to make sure all users get to use it right away.