From 21058ead4de4ebfff7d964d2ee189781d954b033 Mon Sep 17 00:00:00 2001 From: Chris Nehren Date: Wed, 1 Oct 2008 19:22:34 +0000 Subject: [PATCH] changed: the list of extensions for the export system to pass through unmodified has been moved to the configuration file under the "exportBianryExtensions" field. --- docs/changelog/7.x.x.txt | 3 +++ docs/upgrades/upgrade_7.6.0-7.6.1.pl | 25 ++++++++++-------- etc/WebGUI.conf.original | 38 +++++++++++++++++++++++++++- lib/WebGUI/AssetExportHtml.pm | 8 +++--- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ff1118871..61a8bfef2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,7 @@ 7.6.1 + - changed: the list of extensions for the export system to pass through + unmodified has been moved to the configuration file under the + "exportBianryExtensions" field. 7.6.0 - added: users may now customize the post received page for the CS diff --git a/docs/upgrades/upgrade_7.6.0-7.6.1.pl b/docs/upgrades/upgrade_7.6.0-7.6.1.pl index 828b96399..7d9d597fc 100644 --- a/docs/upgrades/upgrade_7.6.0-7.6.1.pl +++ b/docs/upgrades/upgrade_7.6.0-7.6.1.pl @@ -27,20 +27,25 @@ my $quiet; # this line required my $session = start(); # this line required - -# upgrade functions go here - +addExportExtensionsToConfigFile($session); finish($session); # this line required #---------------------------------------------------------------------------- -# Describe what our function does -#sub exampleFunction { -# my $session = shift; -# print "\tWe're doing some stuff here that you should know about... " unless $quiet; -# # and here's our code -# print "DONE!\n" unless $quiet; -#} +# make sure each config file has the extensions to export as-is. however, if +# this system received a backport, leave the field as is. +sub addExportExtensionsToConfigFile { + my $session = shift; + + # skip if the field has been defined already by backporting + return if defined $session->config->get('exportBinaryExtensions'); + + # otherwise, set the field + $session->config->set('exportBinaryExtensions', + [ qw/.html .htm .txt .pdf .jpg .css .gif .png .doc .xls .xml .rss .bmp + .mp3 .js .fla .flv .swf .pl .php .php3 .php4 .php5 .ppt .docx .zip .tar + .rar .gz .bz2/ ] ); +} # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index feeeacc43..379cbc80b 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -830,7 +830,43 @@ "WebGUI::Content::Shop", "WebGUI::Content::Asset", "WebGUI::Content::NotFound" - ] + ], + + +# extensions that the export system should pass through as-is instead of using +# index.html +"exportBinaryExtensions" : [ + ".html", + ".htm", + ".txt", + ".pdf", + ".jpg", + ".css", + ".gif", + ".png", + ".doc", + ".xls", + ".xml", + ".rss", + ".bmp", + ".mp3", + ".js", + ".fla", + ".flv", + ".swf", + ".pl", + ".php", + ".php3", + ".php4", + ".php5", + ".ppt", + ".docx", + ".zip", + ".tar", + ".rar", + ".gz", + ".bz2" +] } diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index 66c976941..68231c8d4 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -528,10 +528,8 @@ sub exportGetUrlAsPath { # if we're still here, it's valid. get it. my $exportPath = $config->get('exportPath'); - # specify a list of file types apache recognises to be passed through as-is - my @fileTypes = qw/.html .htm .txt .pdf .jpg .css .gif .png .doc .xls .xml - .rss .bmp .mp3 .js .fla .flv .swf .pl .php .php3 .php4 .php5 .ppt .docx - .zip .tar .rar .gz .bz2/; + # get a list of file types to pass through as-is + my $fileTypes = $config->get('exportBinaryExtensions'); # get the asset's URL as a URI::URL object for easy parsing of components my $url = URI::URL->new($config->get("sitename")->[0] . $self->getUrl); @@ -550,7 +548,7 @@ sub exportGetUrlAsPath { # check if the file type is recognised by apache. if it is, return it # as-is. if not, slap on the directory separator, $index, and return # it. - if( isIn($extension, @fileTypes) ) { + if( isIn($extension, @{ $fileTypes } ) ) { return Path::Class::File->new($exportPath, @pathComponents, $filename); } else { # don't know what it is