Skip to content

Commit

Permalink
Fix CSP errors in MantisGraph plugin (#881)
Browse files Browse the repository at this point in the history
Fixes #21653
  • Loading branch information
vboctor committed Sep 20, 2016
1 parent a272baf commit bad2c14
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion plugins/MantisGraph/MantisGraph.php
Expand Up @@ -70,7 +70,21 @@ function hooks() {
*/
function csp_headers() {
if ( config_get_global( 'cdn_enabled' ) == ON ) {
http_csp_add( 'script-src', 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' );
http_csp_add( 'script-src', 'https://cdnjs.cloudflare.com' );
}

# Enable inline scripts for MantisGraph plugin pages unless the need for inline
# scripts is removed.
$t_page = gpc_get_string( 'page', '' );
if ( !is_blank( $t_page ) ) {
$t_pos = stripos( $t_page, '/' );

if ( $t_pos !== false ) {
$t_page = substr( $t_page, $t_pos + 1 );
if ( $_SERVER['REQUEST_URI'] == plugin_page( $t_page ) ) {
http_csp_add( 'script-src', "'unsafe-inline'" );
}
}
}
}

Expand Down

0 comments on commit bad2c14

Please sign in to comment.