summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fearn <jfearn@redhat.com>2020-06-09 13:27:23 +1000
committerJeff Fearn <jfearn@redhat.com>2020-07-17 09:28:02 +1000
commitc11f9c574c173e3743e0c8e3d5bca0ed75714c68 (patch)
tree84b0a396d051d47ea2a24f1e0b9f9452e5dcba18
parentBug 1843744 - Add variable name reuse check to perl critic tests (diff)
downloadbugzilla-c11f9c574c173e3743e0c8e3d5bca0ed75714c68.tar.gz
bugzilla-c11f9c574c173e3743e0c8e3d5bca0ed75714c68.tar.bz2
bugzilla-c11f9c574c173e3743e0c8e3d5bca0ed75714c68.zip
Bug 1827524 - JS still doesn't seem to be updated properly after an upgrade
Track md5 of file content. Change-Id: I6f2148352a1ae5cd2f5074d7e997620d7b595f87
-rw-r--r--Bugzilla/Template.pm18
-rw-r--r--extensions/RedHat/template/en/default/hook/global/header-start.html.tmpl2
2 files changed, 12 insertions, 8 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index b58f83626..35ccf0996 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -31,6 +31,7 @@ use Cwd qw(abs_path);
use MIME::Base64;
use Date::Format ();
use Digest::MD5 qw(md5_hex);
+use Encode qw(encode_utf8);
use File::Basename qw(basename dirname);
use File::Find;
use File::Path qw(rmtree mkpath);
@@ -537,12 +538,13 @@ sub _concatenate_css {
# build minified files
my @minified;
+ my @md5s;
foreach my $source (@sources) {
next unless -e "$cgi_path/$files{$source}";
my $file = $skins_path . '/' . md5_hex($source) . '.css';
if (!-e $file) {
my $content = read_text("$cgi_path/$files{$source}");
-
+ push(@md5s, md5_hex(encode_utf8($content)));
# minify
$content =~ s{/\*.*?\*/}{}sg; # comments
$content =~ s{(^\s+|\s+$)}{}mg; # leading/trailing whitespace
@@ -556,8 +558,10 @@ sub _concatenate_css {
push @minified, $file;
}
- # concat files
- my $file = $skins_path . '/' . md5_hex(join(' ', @sources)) . '.css';
+ # concat files, use md5s to detect content changes
+ my $file = $skins_path . '/' . md5_hex(join(' ', @md5s)) . '.css';
+ Bugzilla->logger->info("checking concat $file");
+ trick_taint($file);
if (!-e $file) {
my $content = '';
foreach my $source (@minified) {
@@ -602,12 +606,13 @@ sub _concatenate_js {
# build minified files
my @minified;
+ my @md5s;
foreach my $source (@$sources) {
next unless -e "$cgi_path/$files{$source}";
my $file = $skins_path . '/' . md5_hex($source) . '.js';
if (!-e $file) {
my $content = read_text("$cgi_path/$files{$source}");
-
+ push(@md5s, md5_hex(encode_utf8($content)));
if ($file !~ m{\.min\.}) {
# minimal minification
## BUGBUG unsafe for things like: ",*/*"
@@ -622,8 +627,9 @@ sub _concatenate_js {
push @minified, $file;
}
- # concat files
- my $file = $skins_path . '/' . md5_hex(join(' ', @$sources)) . '.js';
+ # concat files, use md5s to detect content changes
+ my $file = $skins_path . '/' . md5_hex(join(' ', @md5s)) . '.js';
+ trick_taint($file);
if (!-e $file) {
my $content = '';
foreach my $source (@minified) {
diff --git a/extensions/RedHat/template/en/default/hook/global/header-start.html.tmpl b/extensions/RedHat/template/en/default/hook/global/header-start.html.tmpl
index 76ca6095b..2c9aedd89 100644
--- a/extensions/RedHat/template/en/default/hook/global/header-start.html.tmpl
+++ b/extensions/RedHat/template/en/default/hook/global/header-start.html.tmpl
@@ -20,5 +20,3 @@
[% javascript_urls.push('extensions/RedHat/web/alertify/alertify.min.js') %]
[% END %]
[% javascript_urls.push('extensions/RedHat/web/js/redhat.js') %]
-[%# Bug 1819762 Change the number here to force the server to rebuild the JS %]
-[% javascript_urls.push('extensions/RedHat/web/js/fake.3.js') %]