Ticket #3889 (closed bug: fixed)

Opened 4 months ago

Last modified 3 months ago

empty file naming strings lead to "String index out of range" errors when saving

Reported by: voiceinsideyou Assigned to:
Priority: normal Milestone: Picard 0.11
Component: Picard Tagger Version: Picard 0.10.0
Keywords: picard rename renaming move string index Cc:
Browser: Netscape, Firefox, Mozilla (Gecko) OS: Windows XP

Description

If your file naming strings happen to be blank/empty (or set to ".") and you have rename or move files turned on; saving files will fail with "String index out of range" errors.

E:  08:40:28 Traceback (most recent call last):
  File "picard\util\thread.pyo", line 61, in run
  File "picard\file.pyo", line 149, in _save_and_rename
  File "picard\file.pyo", line 236, in _rename
  File "picard\file.pyo", line 229, in _make_filename
IndexError: string index out of range

This is due to http://bazaar.launchpad.net/~musicbrainz-developers/picard/trunk/annotate/819?file_id=file.py-20060829081322-80y9s08yxuaxoaue-20

228 		            if new_filename[0] == '.':
229 		                new_filename = '_' + new_filename[1:] 

where it tries to append the "rest" of the filename; if there is no "rest", i.e. new_filename = "." at that point; it will fail with said error.

Ideally it wouldn't get to this point with an invalid file naming string. Possibly could some validation be added; both in the "Options" dialog and potentially later on (at save-time), to make the error less opaque?

Attachments

Change History

2008-08-04 10:07:04 changed by outsidecontext

Oh, that was me :(

I think what you suggest is the correct way to handle this: This error should be removed and there should be some check earlier to prevent those situations.

2008-08-04 10:12:38 changed by voiceinsideyou

:) No big deal; the code is trying to do something valid and I don't know what would happen if it actually passed that line of code anyway; obviously move/rename isn't valid on an empty string or ".".

http://forums.musicbrainz.org/viewtopic.php?id=1238 is the thread that triggered it, forgot to link back in my note.

2008-08-18 17:45:01 changed by outsidecontext

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to Picard 0.11.

Fixed in revision 825.


Add/Change #3889 (empty file naming strings lead to "String index out of range" errors when saving)




Action