@@ -171,16 +171,16 @@ const TrustedSVGSources = [
171
171
'www.versioneye.com'
172
172
] ;
173
173
174
- function isHostTrusted ( host : string ) : boolean {
175
- return TrustedSVGSources . indexOf ( host . toLowerCase ( ) ) > - 1 ;
176
- }
177
-
178
174
function isGitHubRepository ( repository : string ) : boolean {
179
175
return / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ | ^ g i t @ g i t h u b \. c o m : / . test ( repository || '' ) ;
180
176
}
181
177
182
178
function isGitHubBadge ( href : string ) : boolean {
183
- return isGitHubRepository ( href ) && / [ A - Z a - z 0 - 9 _ - ] { 1 , 100 } \/ w o r k f l o w s \/ [ ^ < > : ; , ? " * | / ] + \/ b a d g e \. s v g $ / . test ( href || '' ) ;
179
+ return / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ [ ^ / ] + \/ [ ^ / ] + \/ w o r k f l o w s \/ .* b a d g e \. s v g / . test ( href || '' ) ;
180
+ }
181
+
182
+ function isHostTrusted ( url : url . UrlWithStringQuery ) : boolean {
183
+ return TrustedSVGSources . indexOf ( url . host . toLowerCase ( ) ) > - 1 || isGitHubBadge ( url . href ) ;
184
184
}
185
185
186
186
class ManifestProcessor extends BaseProcessor {
@@ -472,7 +472,7 @@ export class MarkdownProcessor extends BaseProcessor {
472
472
throw new Error ( `Images in ${ this . name } must come from an HTTPS source: ${ src } ` ) ;
473
473
}
474
474
475
- if ( / \. s v g $ / i. test ( srcUrl . pathname ) && ( ! isHostTrusted ( srcUrl . host ) && ! isGitHubBadge ( srcUrl . href ) ) ) {
475
+ if ( / \. s v g $ / i. test ( srcUrl . pathname ) && ( ! isHostTrusted ( srcUrl ) ) ) {
476
476
throw new Error ( `SVGs are restricted in ${ this . name } ; please use other file image formats, such as PNG: ${ src } ` ) ;
477
477
}
478
478
} ) ;
@@ -717,7 +717,7 @@ export function validateManifest(manifest: Manifest): Manifest {
717
717
throw new Error ( `Badge URLs must come from an HTTPS source: ${ badge . url } ` ) ;
718
718
}
719
719
720
- if ( / \. s v g $ / i. test ( srcUrl . pathname ) && ( ! isHostTrusted ( srcUrl . host ) && ! isGitHubBadge ( srcUrl . href ) ) ) {
720
+ if ( / \. s v g $ / i. test ( srcUrl . pathname ) && ( ! isHostTrusted ( srcUrl ) ) ) {
721
721
throw new Error ( `Badge SVGs are restricted. Please use other file image formats, such as PNG: ${ badge . url } ` ) ;
722
722
}
723
723
} ) ;
0 commit comments