Skip to content

Commit

Permalink
Remove secureHtml, decodeSrcTags and decodeHrefTags in process mosaic…
Browse files Browse the repository at this point in the history
…o html render
  • Loading branch information
FlorianGille committed Dec 10, 2024
1 parent 6f1b91e commit eb52475
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions packages/server/utils/process-mosaico-html-render.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const _ = require('lodash');
const htmlEntities = require('he');

// Tiny MCE can add some not wanted <BR> tags
// • this can break up a layout on email clients
Expand All @@ -20,43 +19,6 @@ function replaceTabs(html) {
return html.replace(/\t/g, ' ');
}

// encode what we can to HTML entities
// → better for mailing
function secureHtml(html) {
return htmlEntities.encode(html, {
useNamedReferences: false,
decimal: true,
allowUnsafeSymbols: true,
});
}

const srcRegexp = /src="(.+?)"/g;
const hrefRegexp = /href="(.+?)"/g;

const decodeTag = (match, tag) => {
return htmlEntities.decode(tag);
};

function decodeSrcTags(html) {
return html.replace(
srcRegexp,
(match, tag) => `src="${decodeTag(match, tag)}"`
);
}

function decodeHrefTags(html) {
return html.replace(
hrefRegexp,
(match, tag) => `href="${decodeTag(match, tag)}"`
);
}

const basicHtmlProcessing = _.flow(
removeTinyMceExtraBrTag,
replaceTabs,
secureHtml,
decodeSrcTags,
decodeHrefTags
);
const basicHtmlProcessing = _.flow(removeTinyMceExtraBrTag, replaceTabs);

module.exports = basicHtmlProcessing;

0 comments on commit eb52475

Please sign in to comment.