Skip to content

Commit 0b7a646

Browse files
authored
Merge pull request #754 from Badsender-com/fix-decode-format-href
Fix: don't encode href and src values
2 parents 11e76c0 + e61306d commit 0b7a646

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

packages/server/utils/process-mosaico-html-render.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function secureHtml(html) {
3333

3434
// We don't want to manage any special format inside href now. We let the reponsability to users to decode
3535
// themselves links in href (but only for href values) that's why we use this regex below
36-
const globalRegexp = /href="(.+?)"/g;
36+
const hrefRegexp = /href="(.+?)"/g;
37+
38+
const srcRegexp = /src="(.+?)"/g;
3739

3840
const decodeTag = (match, tag, fun = (value) => value) => {
3941
let decodedTag = htmlEntities.decode(tag);
@@ -45,18 +47,26 @@ const decodeTag = (match, tag, fun = (value) => value) => {
4547
return decodedTag;
4648
};
4749

48-
function decodeGlobalTags(html) {
50+
function decodeHrefTags(html) {
4951
return html.replace(
50-
globalRegexp,
52+
hrefRegexp,
5153
(match, tag) => `href="${decodeTag(match, tag)}"`
5254
);
5355
}
5456

57+
function decodeSrcTags(html) {
58+
return html.replace(
59+
srcRegexp,
60+
(match, tag) => `src="${decodeTag(match, tag)}"`
61+
);
62+
}
63+
5564
const basicHtmlProcessing = _.flow(
5665
removeTinyMceExtraBrTag,
5766
replaceTabs,
5867
secureHtml,
59-
decodeGlobalTags
68+
decodeHrefTags,
69+
decodeSrcTags
6070
);
6171

6272
module.exports = basicHtmlProcessing;

0 commit comments

Comments
 (0)