@@ -198,9 +198,9 @@ const ALLOWED_ATTR: Record<string, string[]> = {
198198 'blockquote' : [ 'data-callout' ] ,
199199 'details' : [ 'open' ] ,
200200 'code' : [ 'class' ] ,
201- 'pre' : [ 'class' , 'style' ] ,
201+ 'pre' : [ 'class' ] ,
202202 'span' : [ 'class' , 'style' ] ,
203- 'div' : [ 'class' , 'style' , ' align'] ,
203+ 'div' : [ 'class' , 'align' ] ,
204204 'p' : [ 'align' ] ,
205205}
206206
@@ -609,8 +609,8 @@ ${html}
609609 // Resolve image URLs (with GitHub blob → raw conversion)
610610 renderer . image = ( { href, title, text } : Tokens . Image ) => {
611611 const resolvedHref = resolveImageUrl ( href , packageName , repoInfo )
612- const titleAttr = title ? ` title="${ title } "` : ''
613- const altAttr = text ? ` alt="${ text } "` : ''
612+ const titleAttr = title ? ` title="${ escapeHtml ( title ) } "` : ''
613+ const altAttr = text ? ` alt="${ escapeHtml ( text ) } "` : ''
614614 return `<img src="${ resolvedHref } "${ altAttr } ${ titleAttr } >`
615615 }
616616
@@ -687,6 +687,13 @@ ${html}
687687 allowedTags : ALLOWED_TAGS ,
688688 allowedAttributes : ALLOWED_ATTR ,
689689 allowedSchemes : [ 'http' , 'https' , 'mailto' ] ,
690+ // disallow styles other than the ones shiki emits
691+ allowedStyles : {
692+ span : {
693+ 'color' : [ / ^ # [ 0 - 9 a - f ] { 3 , 8 } $ / i] ,
694+ '--shiki-light' : [ / ^ # [ 0 - 9 a - f ] { 3 , 8 } $ / i] ,
695+ } ,
696+ } ,
690697 // Transform img src URLs (GitHub blob → raw, relative → GitHub raw)
691698 transformTags : {
692699 // Headings are already processed to correct semantic levels by processHeading()
0 commit comments