Commit a4599dde authored by Gervase Markham's avatar Gervase Markham Committed by Gervase Markham

Expand max length of attachment filename from 100 to 255 characters. r=glob, a=LpSolit.

parent 4badf488
......@@ -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;
......
......@@ -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
......
......@@ -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'}},
......
......@@ -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 " .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment