diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-07-01 13:43:32 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-07-01 13:43:32 -0400 |
commit | 7cd40ea4eb8955765dc3e61dd3edaf08d1bbab48 (patch) | |
tree | ecae069299e4589457831784bda06abfe6ce8375 | |
parent | 5aee8d937d694dc5ae43b85c6d81ce9d268d1626 (diff) |
better approach for cgi upload disabling
Make it a config setting, this way subtle load order issues don't come into
play. (As much?)
-rw-r--r-- | IkiWiki.pm | 1 | ||||
-rw-r--r-- | IkiWiki/CGI.pm | 6 | ||||
-rw-r--r-- | IkiWiki/Plugin/attachment.pm | 9 |
3 files changed, 11 insertions, 5 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 7d5668d74..d9b3dcdb4 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -88,6 +88,7 @@ sub defaultconfig () { #{{{ account_creation_password => "", prefix_directives => 0, hardlink => 0, + cgi_disable_uploads => 1, } #}}} sub checkconfig () { #{{{ diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 2805534fc..07e92322f 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -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; diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index d2989bb8b..106660012 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -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}; |