From 8cd0a76d1034d582ff0cfde986331324369294f7 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 13 Feb 2018 13:20:24 +0000 Subject: [PATCH] Bug 20187: New rewrite rules can break custom css Koha has the ability to include custom css in the apache configuration. If a library has any custom css ( or adds a custom js file in some way ), and that file has an underscore in it ( e.g. my_custom.css ), the apache rewrite rule will convert it to my.css and thus it will 404. We should make the rewrite rules as specific as possible for the format we are using. Test Plan: 1) Set OPAC_CSS_OVERRIDE to a file with an underscore in it 2) Note it does not work 3) Apply this patch 4) Update the apache rewrite rules to match those in the patch For kohadevbox, just run /home/vagrant/misc4dev/cp_debian_files.pl 5) Restart apache 6) Reload the page, your custom css should load now! Signed-off-by: Victor Grousset Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- debian/templates/apache-shared-intranet.conf | 4 ++-- debian/templates/apache-shared-opac.conf | 4 ++-- etc/koha-httpd.conf | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/debian/templates/apache-shared-intranet.conf b/debian/templates/apache-shared-intranet.conf index 0fb4fdbfa4..fd4a4d9181 100644 --- a/debian/templates/apache-shared-intranet.conf +++ b/debian/templates/apache-shared-intranet.conf @@ -17,8 +17,8 @@ RewriteRule (.+) $1?%1%2 [N,R,NE] RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT] RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT] RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] -RewriteRule ^(.*)_(.*).js$ $1.js [N,L] -RewriteRule ^(.*)_(.*).css$ $1.css [N,L] +RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].js$ $1.js [N,L] +RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].css$ $1.css [N,L] Alias "/api" "/usr/share/koha/api" diff --git a/debian/templates/apache-shared-opac.conf b/debian/templates/apache-shared-opac.conf index e63ab1c26c..68823a4586 100644 --- a/debian/templates/apache-shared-opac.conf +++ b/debian/templates/apache-shared-opac.conf @@ -17,8 +17,8 @@ RewriteRule (.+) $1?%1%2 [N,R,NE] RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT] RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT] RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] -RewriteRule ^(.*)_(.*).js$ $1.js [N,L] -RewriteRule ^(.*)_(.*).css$ $1.css [N,L] +RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].js$ $1.js [N,L] +RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].css$ $1.css [N,L] = 2.4> AliasMatch "^/sitemap(.*)" "/var/lib/koha/${instance}/sitemap/sitemap$1" diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf index 327956fce1..2fed351178 100644 --- a/etc/koha-httpd.conf +++ b/etc/koha-httpd.conf @@ -111,8 +111,8 @@ RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT] RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT] RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] - RewriteRule ^(.*)_(.*).js$ $1.js [N,L] - RewriteRule ^(.*)_(.*).css$ $1.css [N,L] + RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].js$ $1.js [N,L] + RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].css$ $1.css [N,L] # REST API configuration Alias "/api" "__API_CGI_DIR__" @@ -238,8 +238,8 @@ RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT] RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT] RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] - RewriteRule ^(.*)_(.*).js$ $1.js [N,L] - RewriteRule ^(.*)_(.*).css$ $1.css [N,L] + RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].js$ $1.js [N,L] + RewriteRule ^(.*)_[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9].css$ $1.css [N,L] # REST API configuration -- 2.39.5