Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 3e04982

Browse files
committed
Stop Medium Editor from preventing sanitization
This restores sanitization to HTML fields, and prevents invalid tags from being used.
1 parent 3df19d4 commit 3e04982

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

js/utils/validateMediumEditor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ function checkVal($field) {
1515
// replace double quotes with single quotes to avoid invalid json
1616
//fVal = fVal.replace(/\\([\s\S])|(")/g, "'");
1717

18+
//decode text the medium editor encodes, or the medium editor will remove it the second time
19+
fVal = decodeHtml(fVal);
20+
1821
fVal = sanitizeHTML(fVal, {
1922
allowedTags: [ 'h2','h3', 'h4', 'h5', 'h6', 'p', 'a','u','ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'hr', 'br', 'img', 'blockquote' ],
2023
//allowedTags: [ 'h2','h3', 'h4', 'h5', 'h6', 'p','u','ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'hr', 'br', 'blockquote' ],
@@ -26,8 +29,7 @@ function checkVal($field) {
2629
return frame.tag === 'p' && !frame.text.trim();
2730
}
2831
});
29-
//decode text the medium editor encodes, or the medium editor will remove it the second time
30-
fVal = decodeHtml(fVal);
32+
3133

3234
$field.val(fVal);
3335

0 commit comments

Comments
 (0)