allow more than a trailing alphanumeric part of an image filename to live
authorTony Cook <tony@develop-help.com>
Mon, 11 May 2015 09:17:59 +0000 (19:17 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 11 May 2015 09:17:59 +0000 (19:17 +1000)
site/cgi-bin/modules/BSE/Edit/Article.pm
site/cgi-bin/modules/DevHelp/FileUpload.pm

index 754412da4359cbd18dae798ae84720043c97047f..813876d487746cdb873968183755b59485a8523e 100644 (file)
@@ -16,7 +16,7 @@ use List::Util qw(first);
 use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
 use constant ARTICLE_CUSTOM_FIELDS_CFG => "article custom fields";
 
-our $VERSION = "1.054";
+our $VERSION = "1.055";
 
 =head1 NAME
 
@@ -3380,11 +3380,8 @@ sub _validate_image {
   }
   my $imagename = $filename;
   $imagename .= ''; # force it into a string
-  my $basename = '';
-  $imagename =~ tr/ //d;
-  $imagename =~ /([\w.-]+)$/ and $basename = $1;
+  (my $basename = $imagename) =~ tr/A-Za-z0-9_./-/cs;
 
-  # for OSs with special text line endings
   require BSE::ImageSize;
 
   my ($width,$height, $type) = BSE::ImageSize::imgsize($fh);
index 3e9e7d4591dbc22a20b6dd4274fdf8b8049dbc67..f9ae7c1cab82a1f14b7d99ee9b246a1e4b60d948 100644 (file)
@@ -3,11 +3,11 @@ use strict;
 use IO::File;
 use File::Copy;
 
-our $VERSION = "1.001";
+our $VERSION = "1.002";
 
 =head1 NAME
 
-  DevHelp::FileUpload - tools to maintain a file upload directory
+DevHelp::FileUpload - tools to maintain a file upload directory
 
 =head1 SYNOPSIS
 
@@ -84,8 +84,7 @@ sub make_fh_copy {
 sub make_img_filename {
   my ($class, $imgdir, $name, $rmsg) = @_;
 
-  my $basename = '';
-  $name =~ /([\w.-]+)$/ and $basename = $1;
+  (my $basename = $name) =~ tr/A-Za-z0-9_./-/cs;
 
   if (length $basename > 60) {
     $basename = substr($basename, -60);