From 5df95f55e7ceba19899dc45b7c229d4ca8c8204e Mon Sep 17 00:00:00 2001 From: Roland Becker Date: Mon, 9 Oct 2017 16:36:43 +0200 Subject: [PATCH] Don't deliver unneeded JavaScript if Graphs plugin is enabled Fixes #23446 --- plugins/MantisGraph/MantisGraph.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/MantisGraph/MantisGraph.php b/plugins/MantisGraph/MantisGraph.php index 3415523c13..2f15430538 100644 --- a/plugins/MantisGraph/MantisGraph.php +++ b/plugins/MantisGraph/MantisGraph.php @@ -99,7 +99,7 @@ function routes( $p_event_name, $p_event_args ) { * @return void */ function csp_headers() { - if ( config_get_global( 'cdn_enabled' ) == ON ) { + if( config_get_global( 'cdn_enabled' ) == ON ) { http_csp_add( 'script-src', 'https://cdnjs.cloudflare.com' ); } } @@ -122,14 +122,16 @@ function graph_filter_menu() { * @return void */ function resources() { - if ( config_get_global( 'cdn_enabled' ) == ON ) { - html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.min.js', CHARTJS_HASH ); - html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.bundle.min.js', CHARTJSBUNDLE_HASH ); - } else { - echo ''; - echo ''; + if( current( explode( '/', gpc_get_string( 'page', '' ) ) ) === $this->basename ) { + if( config_get_global( 'cdn_enabled' ) == ON ) { + html_javascript_cdn_link('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.min.js', CHARTJS_HASH); + html_javascript_cdn_link('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.bundle.min.js', CHARTJSBUNDLE_HASH); + } else { + echo ''; + echo ''; + } + echo ''; } - echo ''; } /**