aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Photo.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-05-22 14:31:56 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-05-22 14:31:56 +0100
commit58365c1fc883f64e6a8c9b4cd70869013c179b69 (patch)
tree1d43d40378ab75064e0336d05267b5673c89ca29 /perllib/FixMyStreet/App/Controller/Photo.pm
parentf7e8651ed36a5579c4025345212d74df01eb2c6d (diff)
Allow through octet-stream uploads, catch error from jhead better.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Photo.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm8
1 files changed, 5 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index a070d71db..a84c538cc 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -163,8 +163,9 @@ sub process_photo_upload : Private {
# check that the photo is a jpeg
my $ct = $upload->type;
- $ct =~ s/x-citrix-//;
- unless ( $ct eq 'image/jpeg' || $ct eq 'image/pjpeg' ) {
+ $ct =~ s/x-citrix-//; # Thanks, Citrix
+ # Had a report of a JPEG from an Android 2.1 coming through as a byte stream
+ unless ( $ct eq 'image/jpeg' || $ct eq 'image/pjpeg' || $ct eq 'application/octet-stream' ) {
$c->stash->{photo_error} = _('Please upload a JPEG image only');
return;
}
@@ -172,7 +173,8 @@ sub process_photo_upload : Private {
# get the photo into a variable
my $photo_blob = eval {
my $filename = $upload->tempname;
- my $out = `jhead -se -autorot $filename`;
+ my $out = `jhead -se -autorot $filename 2>&1`;
+ die _("Please upload a JPEG image only"."\n") if $out =~ /Not JPEG:/;
my $photo = $upload->slurp;
return $photo;
};