File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
workbench/contrib/markdown/browser Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ export interface MarkdownSanitizerConfig {
5656 readonly allowedTags ?: {
5757 readonly override : readonly string [ ] ;
5858 } ;
59+ readonly allowedAttributes ?: {
60+ readonly override : readonly string [ ] ;
61+ } ;
5962 readonly customAttrSanitizer ?: ( attrName : string , attrValue : string ) => boolean | string ;
6063 readonly allowedLinkSchemes ?: {
6164 readonly augment : readonly string [ ] ;
@@ -510,7 +513,7 @@ function getDomSanitizerConfig(isTrusted: boolean | MarkdownStringTrustedOptions
510513 override : options . allowedTags ?. override ?? allowedMarkdownHtmlTags
511514 } ,
512515 allowedAttributes : {
513- override : allowedMarkdownHtmlAttributes ,
516+ override : options . allowedAttributes ?. override ?? allowedMarkdownHtmlAttributes ,
514517 } ,
515518 allowedLinkProtocols : {
516519 override : allowedLinkSchemes ,
Original file line number Diff line number Diff line change @@ -22,14 +22,27 @@ export class MarkedKatexSupport {
2222 ...trustedMathMlTags ,
2323 ]
2424 } ,
25+ allowedAttributes : {
26+ override : [
27+ ...baseConfig . allowedAttributes ,
28+ // Math
29+ 'stretchy' ,
30+ 'encoding' ,
31+ 'accent' ,
32+ // SVG
33+ 'd' ,
34+ 'viewBox' ,
35+ 'preserveAspectRatio' ,
36+ ]
37+ } ,
2538 customAttrSanitizer : ( attrName , attrValue ) => {
2639 if ( attrName === 'class' ) {
2740 return true ; // TODO: allows all classes for now since we don't have a list of possible katex classes
2841 } else if ( attrName === 'style' ) {
2942 return this . sanitizeKatexStyles ( attrValue ) ;
3043 }
3144
32- return baseConfig . allowedAttributes . includes ( attrName ) ;
45+ return true ; // Allow through other attrs. Our allow list already filtered out bad ones
3346 } ,
3447 } ;
3548 }
You can’t perform that action at this time.
0 commit comments