File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 5353 },
5454 "dependencies" : {
5555 "body-parser" : " ~1.18.2" ,
56+ "cheerio" : " ^1.0.0-rc.2" ,
5657 "compression" : " ~1.7.1" ,
5758 "cors" : " ~2.8.4" ,
5859 "crypto" : " ~1.0.1" ,
Original file line number Diff line number Diff line change 11const sanitizeHtml = require ( 'sanitize-html' ) ;
2- const embedToAnchor = require ( 'quill-url-embeds/dist/embed-to-anchor' ) ;
2+ // const embedToAnchor = require('quill-url-embeds/dist/embed-to-anchor');
33const _ = require ( 'lodash' ) ;
4+ const cheerio = require ( 'cheerio' ) ;
5+
6+ const embedToAnchor = ( content ) => {
7+ const $ = cheerio . load ( content ) ;
8+ $ ( 'div[data-url-embed]' ) . each ( ( i , el ) => {
9+ let url = el . attribs [ 'data-url-embed' ] ;
10+ let aTag = $ ( `<a href="${ url } " target="_blank" data-url-embed="">${ url } </a>` ) ;
11+ $ ( el ) . replaceWith ( aTag ) ;
12+ } ) ;
13+ return $ ( 'body' ) . html ( ) ;
14+ } ;
415
516function clean ( dirty ) {
617 // Convert embeds to a-tags
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ module.exports = {
103103 isVerified ( )
104104 ) ,
105105 associateCurrentUser ( ) ,
106- // xss({ fields: ['content', 'contentExcerpt'] }),
106+ xss ( { fields : [ 'content' , 'contentExcerpt' ] } ) ,
107107 createSlug ( { field : 'title' } ) ,
108108 saveRemoteImages ( [ 'teaserImg' ] ) ,
109109 createExcerpt ( )
@@ -117,7 +117,7 @@ module.exports = {
117117 excludeDisabled ( ) ,
118118 restrictToOwner ( )
119119 ) ,
120- // xss({ fields: ['content', 'contentExcerpt'] }),
120+ xss ( { fields : [ 'content' , 'contentExcerpt' ] } ) ,
121121 saveRemoteImages ( [ 'teaserImg' ] ) ,
122122 createExcerpt ( )
123123 ] ,
@@ -130,7 +130,7 @@ module.exports = {
130130 excludeDisabled ( ) ,
131131 restrictToOwner ( )
132132 ) ,
133- // xss({ fields: ['content', 'contentExcerpt'] }),
133+ xss ( { fields : [ 'content' , 'contentExcerpt' ] } ) ,
134134 saveRemoteImages ( [ 'teaserImg' ] ) ,
135135 createExcerpt ( )
136136 ] ,
You can’t perform that action at this time.
0 commit comments