pixelcog / gmail-to-pdf

A Google Apps Script library for converting Gmail messages to PDFs for easy archival.
http://bit.ly/1CsBl8U
123 stars 38 forks source link

in PDF, Body is empty with certain emails, because the function processStyleTags(html) breaks the </style> ending tag #18

Open emmanueljarri opened 3 years ago

emmanueljarri commented 3 years ago

With some emails, when a style tag is present (ex : in a group, and then would catch a position number and would replace the end tag with the location number, thus breaking the HTML syntax, thus implying a blank body in the generated PDF.

This is the original regex , with the wrongfully "NO CATCH" instruction :

return html.replace(/(<style[^>]*>)(.*?)(?:<\/style>)/gi, function(m, tag, style, end) {

This is the one modified to DO CATCH the ending tag so it's correctly stored in the "end" variable and then correctly put back at the end : (without the non capturing "?:" :

return html.replace(/(<style[^>]*>)(.*?)(<\/style>)/gi, function(m, tag, style, end) {

Now for me it does generate the PDF correctly for emails with