aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/attachment.pm33
-rw-r--r--IkiWiki/Wrapper.pm2
2 files changed, 19 insertions, 16 deletions
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index 6004a0982..4af9ac92b 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -252,22 +252,25 @@ sub attachment_store {
IkiWiki::fast_file_copy($tempfile, $filename, $fh, @_);
});
}
-
+
# Return JSON response for the jquery file upload widget.
- eval q{use JSON};
- error $@ if $@;
- print "Content-type: application/json\n\n";
- my $size=-s $dest."/".$filename;
- print to_json([
- {
- name => $filename,
- size => $size,
- humansize => IkiWiki::Plugin::filecheck::humansize($size),
- stored_msg => stored_msg(),
-
- }
- ]);
- exit 0;
+ if ($q->Accept("application/json") >= 1.0 &&
+ grep { /application\/json/i } $q->Accept) {
+ eval q{use JSON};
+ error $@ if $@;
+ print "Content-type: application/json\n\n";
+ my $size=-s $dest."/".$filename;
+ print to_json([
+ {
+ name => $filename,
+ size => $size,
+ humansize => IkiWiki::Plugin::filecheck::humansize($size),
+ stored_msg => stored_msg(),
+
+ }
+ ]);
+ exit 0;
+ }
}
# Save all stored attachments for a page.
diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm
index 4fe2d8111..d39a3ea40 100644
--- a/IkiWiki/Wrapper.pm
+++ b/IkiWiki/Wrapper.pm
@@ -49,7 +49,7 @@ sub gen_wrapper () {
push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE
HTTP_COOKIE REMOTE_USER HTTPS REDIRECT_STATUS
- HTTP_HOST SERVER_PORT HTTPS
+ HTTP_HOST SERVER_PORT HTTPS HTTP_ACCEPT
REDIRECT_URL} if $config{cgi};
my $envsave="";
foreach my $var (@envsave) {