]> sipb.mit.edu Git - ikiwiki.git/commitdiff
better approach for cgi upload disabling
authorJoey Hess <joey@kodama.kitenet.net>
Tue, 1 Jul 2008 17:43:32 +0000 (13:43 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Tue, 1 Jul 2008 17:43:32 +0000 (13:43 -0400)
Make it a config setting, this way subtle load order issues don't come into
play. (As much?)

IkiWiki.pm
IkiWiki/CGI.pm
IkiWiki/Plugin/attachment.pm

index 7d5668d74d6899f08019b964517223b693606db5..d9b3dcdb473df66c4505a1b47e429febac493b63 100644 (file)
@@ -88,6 +88,7 @@ sub defaultconfig () { #{{{
        account_creation_password => "",
        prefix_directives => 0,
        hardlink => 0,
+       cgi_disable_uploads => 1,
 } #}}}
 
 sub checkconfig () { #{{{
index 2805534fcb67c42c8fd40ecbc9fd7672085ecd43..07e92322f4cbf94b9af112890077bd093f94b89d 100644 (file)
@@ -6,8 +6,6 @@ use IkiWiki;
 use IkiWiki::UserInfo;
 use open qw{:utf8 :std};
 use Encode;
-use CGI;
-$CGI::DISABLE_UPLOADS=1;
 
 package IkiWiki;
 
@@ -668,6 +666,10 @@ sub cgi (;$$) { #{{{
        my $q=shift;
        my $session=shift;
 
+       eval q{use CGI};
+       error($@) if $@;
+       $CGI::DISABLE_UPLOADS=$config{cgi_disable_uploads};
+
        if (! $q) {
                binmode(STDIN);
                $q=CGI->new;
index d2989bb8b8b45d625269a6ae7b96fd37428dad0e..106660012cb31029a62cc8b703b8558655e57440 100644 (file)
@@ -4,18 +4,21 @@ package IkiWiki::Plugin::attachment;
 use warnings;
 use strict;
 use IkiWiki 2.00;
-use CGI;
-$CGI::DISABLE_UPLOADS=0;
 
 # TODO move to admin prefs
 $config{valid_attachments}="(*.mp3 and maxsize(15mb)) or (!ispage() and maxsize(50kb))";
 
 sub import { #{{{
+       hook(type => "checkconfig", id => "attachment", call => \&checkconfig);
        hook(type => "formbuilder_setup", id => "attachment", call => \&formbuilder_setup);
        hook(type => "formbuilder", id => "attachment", call => \&formbuilder);
 } # }}}
 
-sub formbuilder_setup { #{{{
+sub checkconfig () { #{{{
+       $config{cgi_disable_uploads}=0;
+} #}}}
+
+sub formbuilder_setup (@) { #{{{
        my %params=@_;
        my $form=$params{form};