src/utils.js
/** Sanitizes html markup that is passed in. This should be used on any
 * content that is user modifiable.
 * @param {string} markup string representation of html from untrusted source
 */
Sanitizes html markup that is passed in. This should be used on any
content that is user modifiable.
@param {string} markup string representation of html from untrusted source
Sanitizes html markup that is passed in . This should be used on any content that is user modifiable . @param { string } markup string representation of html from untrusted source
function cleanHtml(markup) {
  return {
    __html: sanitizeHtml(markup, {
      allowedTags: sanitizeHtml.defaults.allowedTags.concat(["a", "button", "iframe", "img", "svg", "circle", "path", "g", "defs", "title"]),
      allowedAttributes: {
        a: ["href"],
        img: ["src", "srcset", "alt"],
        svg: ["xmlns", "viewBox"],
        circle: ["cx", "cy", "r", "fill"],
        path: ["d", "fill"],
        g: ["fill"],
        "*": ["class", "id", "data-*"],
        iframe: ['src', 'title', 'referrerpolicy', 'scrolling']
      },
      allowedIframeHostnames: ['www.youtube.com', 'stream.inspiringhopechurch.com'],
      transformTags: {
        'table': sanitizeHtml.simpleTransform('table', { class: 'table is-size-6 is-striped is-narrow' }),
        'iframe': sanitizeHtml.simpleTransform('iframe', { class: 'has-ratio' }),
      },
      parser: {
        lowerCaseAttributeNames: false 
      }
    }),
  };
}
function cleanHtml ( markup ) { return { __html : sanitizeHtml ( markup , { allowedTags : sanitizeHtml . defaults . allowedTags . concat ( [ "a" , "button" , "iframe" , "img" , "svg" , "circle" , "path" , "g" , "defs" , "title" ] ) , allowedAttributes : { a : [ "href" ] , img : [ "src" , "srcset" , "alt" ] , svg : [ "xmlns" , "viewBox" ] , circle : [ "cx" , "cy" , "r" , "fill" ] , path : [ "d" , "fill" ] , g : [ "fill" ] , "*" : [ "class" , "id" , "data-*" ] , iframe : [ 'src' , 'title' , 'referrerpolicy' , 'scrolling' ] } , allowedIframeHostnames : [ 'www.youtube.com' , 'stream.inspiringhopechurch.com' ] , transformTags : { 'table' : sanitizeHtml . simpleTransform ( 'table' , { class : 'table is-size-6 is-striped is-narrow' } ) , 'iframe' : sanitizeHtml . simpleTransform ( 'iframe' , { class : 'has-ratio' } ) , } , parser : { lowerCaseAttributeNames : false } } ) , } ; }
Sanitizes html markup that is passed in.
Sanitizes html markup that is passed in .
// prevents xml attributes, e.g. viewBox, from being lowercased