Booru-mass-uploader icon indicating copy to clipboard operation
Booru-mass-uploader copied to clipboard

Filenames with spaces are truncated to the last word dot extension

Open duanemoody opened this issue 4 years ago • 3 comments

If you've checkmarked Set Title of each image to its original filename, this is a picture.gif becomes picture.gif in the title field. I suspect this regex in uploader.js is to blame: tags = fileName; title = upOptions.title ? tags.split(/\s+/)[tags.split(/\s+/).length - 1] : ''; It's assuming "last space is delimiter to filename inside fileName" which only works if the filename has no spaces in it. If I've read the source correctly, fileName is actually "[rating] [tags] [filename]" where an array would be safer to parse: fileInfo['rating'], fileInfo['tags'], fileInfo['filename']

duanemoody avatar Dec 02 '20 18:12 duanemoody

Yes, but how would we separate filename from tags if it has spaces as well?

Seedmanc avatar Dec 03 '20 19:12 Seedmanc

Two choices:

  1. bandaid: Use a nonprinting delimiter character that's illegal in most file systems like ESC
  2. better practices: Stop using string packing as a way to attack this problam and pass myArray = [rating,tags] using formData.append('myArray',myArray[])

duanemoody avatar Dec 06 '20 19:12 duanemoody

Not quite sure what you mean by (2), doesn't the problem lie in file naming, it would be too late to fix it at the uploading stage? It's either stating clearly in the Readme that the files shouldn't have spaces in their name part, or using a special character or multiple spaces to delimit tags from the actual name.

I would opt for an easier solution, since I'm no longer actively developing this project and the last thing I want to do is to break something.

Seedmanc avatar Dec 12 '20 11:12 Seedmanc