aboutsummaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorGervase Markham <gerv@gerv.net>2011-12-08 12:47:39 +0000
committerGervase Markham <gerv@mozilla.org>2011-12-08 12:47:39 +0000
commita4599dde03c31fec1000c8358d6daa04e1801139 (patch)
tree1f01c6e68f1989ab15b782cf1fe388d049ca6389 /Bugzilla
parent4badf488d539d7e50c7a156ecc65514796e6345a (diff)
downloadbugs-a4599dde03c31fec1000c8358d6daa04e1801139.tar
bugs-a4599dde03c31fec1000c8358d6daa04e1801139.tar.gz
bugs-a4599dde03c31fec1000c8358d6daa04e1801139.tar.bz2
bugs-a4599dde03c31fec1000c8358d6daa04e1801139.tar.xz
bugs-a4599dde03c31fec1000c8358d6daa04e1801139.zip
Expand max length of attachment filename from 100 to 255 characters. r=glob, a=LpSolit.
https://bugzilla.mozilla.org/show_bug.cgi?id=705078
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Attachment.pm8
-rw-r--r--Bugzilla/Constants.pm6
-rw-r--r--Bugzilla/DB/Schema.pm2
-rw-r--r--Bugzilla/Install/DB.pm6
4 files changed, 17 insertions, 5 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 6c39818f6..53a3e9147 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -581,9 +581,11 @@ sub _check_filename {
# a big deal if it munges incorrectly occasionally.
$filename =~ s/^.*[\/\\]//;
- # Truncate the filename to 100 characters, counting from the end of the
- # string to make sure we keep the filename extension.
- $filename = substr($filename, -100, 100);
+ # Truncate the filename to MAX_ATTACH_FILENAME_LENGTH characters, counting
+ # from the end of the string to make sure we keep the filename extension.
+ $filename = substr($filename,
+ -MAX_ATTACH_FILENAME_LENGTH,
+ MAX_ATTACH_FILENAME_LENGTH);
trick_taint($filename);
return $filename;
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index b63d222b1..1df41fec5 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -182,6 +182,7 @@ use Memoize;
MAX_FREETEXT_LENGTH
MAX_BUG_URL_LENGTH
MAX_POSSIBLE_DUPLICATES
+ MAX_ATTACH_FILENAME_LENGTH
PASSWORD_DIGEST_ALGORITHM
PASSWORD_SALT_LENGTH
@@ -563,6 +564,11 @@ use constant MAX_BUG_URL_LENGTH => 255;
# will return.
use constant MAX_POSSIBLE_DUPLICATES => 25;
+# Maximum length of filename stored in attachments table (longer ones will
+# be truncated to this value). Do not increase above 255 without making the
+# necessary schema changes to store longer names.
+use constant MAX_ATTACH_FILENAME_LENGTH => 255;
+
# This is the name of the algorithm used to hash passwords before storing
# them in the database. This can be any string that is valid to pass to
# Perl's "Digest" module. Note that if you change this, it won't take
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 6d9a33ef7..f6612e518 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -451,7 +451,7 @@ use constant ABSTRACT_SCHEMA => {
mimetype => {TYPE => 'TINYTEXT', NOTNULL => 1},
ispatch => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
- filename => {TYPE => 'varchar(100)', NOTNULL => 1},
+ filename => {TYPE => 'varchar(255)', NOTNULL => 1},
submitter_id => {TYPE => 'INT3', NOTNULL => 1,
REFERENCES => {TABLE => 'profiles',
COLUMN => 'userid'}},
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 84267de41..b9f5d112d 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -658,6 +658,10 @@ sub update_table_definitions {
# 2011-10-11 miketosh - Bug 690173
_on_delete_set_null_for_audit_log_userid();
+
+ # 2011-11-23 gerv@gerv.net - Bug 705058 - make filenames longer
+ $dbh->bz_alter_column('attachments', 'filename',
+ { TYPE => 'varchar(255)', NOTNULL => 1 });
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
@@ -2204,7 +2208,7 @@ sub _convert_attachments_filename_from_mediumtext {
# shouldn't be there for security. Buggy browsers include them,
# and attachment.cgi now takes them out, but old ones need converting.
my $ref = $dbh->bz_column_info("attachments", "filename");
- if ($ref->{TYPE} ne 'varchar(100)') {
+ if ($ref->{TYPE} ne 'varchar(100)' && $ref->{TYPE} ne 'varchar(255)') {
print "Removing paths from filenames in attachments table...";
my $sth = $dbh->prepare("SELECT attach_id, filename FROM attachments " .