Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: Attachment file name is too long #3820

Closed
Ben-MyBB opened this issue Oct 22, 2019 · 2 comments · Fixed by #3824
Closed

error: Attachment file name is too long #3820

Ben-MyBB opened this issue Oct 22, 2019 · 2 comments · Fixed by #3824
Assignees
Labels
b:1.8 Branch: 1.8.x s:resolved Status: Resolved. Solution implemented or scheduled t:bug Type: Bug. An issue causing error / flaw / malfunction
Milestone

Comments

@Ben-MyBB
Copy link
Member

When uploading an attachment, if the filename is longer than the field length, I get an error. This can happen if the filename details photo content.
Quote:SQL Error: 1406 - Data too long for column 'filename' at row 1
Query:
                        INSERT
                        INTO mybb_attachments (pid,posthash,uid,filename,filetype,filesize,attachname,downloads,dateuploaded,thumbnail,visible)
                        VALUES (0,'82308f13b0ceb97b6b3d8988ef3af7a2','262','Marlene Dietrich, Jean Harlow, Joan Blondell (looking bored unknown ( Elizabeth Allan), Edward G. Robinson, and Dolores del Rio..jpg','image/jpeg',80341,'201910/post_262_1571487304_daacdaa987c4bdbfdf717ea2d58b462c.attach',0,1571487304,'201910/post_262_1571487304_daacdaa987c4bdbfdf717ea2d58b462c_thumb.jpg',1)

Error is backtraced to /inc/functions_upload.php line 764.

I have increased field length in table mybb_attachments / filename from varchar(120) to varchar(200). I hope this does not have unintended consequences. This option is better than allowing the field to be truncated by dropping STRICT_TRANS_TABLES from sql-mode.

However, a better solution would be validation of the filename length and generating an error message similar to what I would get if filesize is too great.

Would this work? Please suggest corrections to syntax.

438      // Check the filename length
439      if(strlen($attachment['filename']) > 120 != "")
440      {
441          $ret['error'] = $lang->sprintf($lang->error_filenamelength, htmlspecialchars_uni($attachment['name']), "120");
442          return $ret;
443      }

It should be obvious I'm attempting to modify an existing portion of code, and it should really be obvious I am not experienced. But I am always willing to learn. :)

Where would I insert the new error message?

Original thread: error: Attachment file name is too long

@Ben-MyBB Ben-MyBB added b:1.8 Branch: 1.8.x s:confirmed Status: Confirmed. Retested and found the issue exists t:bug Type: Bug. An issue causing error / flaw / malfunction labels Oct 22, 2019
@yuliu
Copy link
Member

yuliu commented Oct 22, 2019

Increase the column length should be the best one for me. See filename length limits in different OSes: https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations (WTF is Smart File System doing??)

According to https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits , some counts by byte, some by character.

@euantorano
Copy link
Member

I would agree with increasing the column length, seems like the best option to me.

@euantorano euantorano added this to the 1.8.22 milestone Nov 4, 2019
@euantorano euantorano self-assigned this Nov 4, 2019
euantorano added a commit to euantorano/mybb that referenced this issue Nov 4, 2019
euantorano added a commit to euantorano/mybb that referenced this issue Nov 4, 2019
@dvz dvz closed this as completed in #3824 Nov 12, 2019
dvz pushed a commit that referenced this issue Nov 12, 2019
* Fix #3820 - extend attachment filename length

* Change path length to 255

* Fix max filename length in error string
@dvz dvz added s:resolved Status: Resolved. Solution implemented or scheduled and removed s:confirmed Status: Confirmed. Retested and found the issue exists labels Nov 12, 2019
lairdshaw pushed a commit to lairdshaw/mybb that referenced this issue Oct 11, 2021
* Fix mybb#3820 - extend attachment filename length

* Change path length to 255

* Fix max filename length in error string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b:1.8 Branch: 1.8.x s:resolved Status: Resolved. Solution implemented or scheduled t:bug Type: Bug. An issue causing error / flaw / malfunction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants