]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Expand max length of attachment filename from 100 to 255 characters. r=glob, a=LpSolit.
authorGervase Markham <gerv@gerv.net>
Thu, 8 Dec 2011 12:47:39 +0000 (12:47 +0000)
committerGervase Markham <gerv@mozilla.org>
Thu, 8 Dec 2011 12:47:39 +0000 (12:47 +0000)
https://bugzilla.mozilla.org/show_bug.cgi?id=705078

Bugzilla/Attachment.pm
Bugzilla/Constants.pm
Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm

index 6c39818f69c9e8ded8fd01160bfe1975c41b0708..53a3e914776ceeabd29493d855579e1c796a65ec 100644 (file)
@@ -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;
index b63d222b19371bf2dd63dcb490293bdc77d0873f..1df41fec51a380169cad02e719ed4c6761339ac8 100644 (file)
@@ -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
index 6d9a33ef7482a596af4379785ce9a933fb759aa8..f6612e51820cb14994a1d20edf13187177a48d95 100644 (file)
@@ -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'}},
index 84267de412eb34623d20c0d38a8ebd1e224d1479..b9f5d112d894d55574e45aa1aec1cfe705af7426 100644 (file)
@@ -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 " .