wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / put.pl
blobcccca771baec77d4fac26e163328b20c5f191053
1 # Copyright (C) 2009 Alex Schroeder <alex@gnu.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 =head1 Put Extension
18 This module allows you to upload wiki pages using the PUT request
19 method. For example:
21 echo test | curl -T - http://www.emacswiki.org/cgi-bin/test/Mu
23 This will replace the Mu page with "test".
25 Note that you cannot use an URL that will be rewritten by Apache
26 mod_rewrite as the target for your PUT request. Apparently mod_rewrite
27 only works reliably for GET requests.
29 =cut
31 push(@MyInitVariables, \&PutMethodHandler);
33 sub PutMethodHandler {
34 if ($q->request_method() eq 'PUT') {
35 my $data;
36 while (<STDIN>) {
37 $data .= $_;
38 # protect against denial of service attacks?
39 if (length($data) > $MaxPost) {
40 ReportError(T('Upload is limited to %s bytes', $MaxPost),
41 '413 REQUEST ENTITY TOO LARGE');
44 SetParam('title', GetId());
45 SetParam('text', $data);