@@ -5,7 +5,7 @@ var CspStrategy = {}
55
66var defaultDirectives = {
77 defaultSrc : [ '\'self\'' ] ,
8- scriptSrc : [ '\'self\'' , 'vimeo.com' , 'https://gist.github.com' , 'www.slideshare.net' , 'https://query.yahooapis.com' , 'https://*.disqus.com' , ' \'unsafe-eval\''] ,
8+ scriptSrc : [ '\'self\'' , 'vimeo.com' , 'https://gist.github.com' , 'www.slideshare.net' , 'https://query.yahooapis.com' , '\'unsafe-eval\'' ] ,
99 // ^ TODO: Remove unsafe-eval - webpack script-loader issues https://github.com/hackmdio/hackmd/issues/594
1010 imgSrc : [ '*' ] ,
1111 styleSrc : [ '\'self\'' , '\'unsafe-inline\'' , 'https://assets-cdn.github.com' ] , // unsafe-inline is required for some libs, plus used in views
@@ -22,11 +22,23 @@ var cdnDirectives = {
2222 fontSrc : [ 'https://cdnjs.cloudflare.com' , 'https://fonts.gstatic.com' ]
2323}
2424
25+ var disqusDirectives = {
26+ scriptSrc : [ 'https://*.disqus.com' , 'https://*.disquscdn.com' ] ,
27+ styleSrc : [ 'https://*.disquscdn.com' ] ,
28+ fontSrc : [ 'https://*.disquscdn.com' ]
29+ }
30+
31+ var googleAnalyticsDirectives = {
32+ scriptSrc : [ 'https://www.google-analytics.com' ]
33+ }
34+
2535CspStrategy . computeDirectives = function ( ) {
2636 var directives = { }
2737 mergeDirectives ( directives , config . csp . directives )
2838 mergeDirectivesIf ( config . csp . addDefaults , directives , defaultDirectives )
2939 mergeDirectivesIf ( config . useCDN , directives , cdnDirectives )
40+ mergeDirectivesIf ( config . csp . addDisqus , directives , disqusDirectives )
41+ mergeDirectivesIf ( config . csp . addGoogleAnalytics , directives , googleAnalyticsDirectives )
3042 if ( ! areAllInlineScriptsAllowed ( directives ) ) {
3143 addInlineScriptExceptions ( directives )
3244 }
0 commit comments