0.83: XnView MP can rename files to too long names

Bugs which have been reproduced by a second user or the developer

Moderator: Dreamer

JMM72
Posts: 26
Joined: Wed Feb 10, 2016 2:16 pm

0.83: XnView MP can rename files to too long names

Postby JMM72 » Thu Dec 22, 2016 12:23 am

Hello. Using: XnViewMP Version 0.83 x64 (Oct 3 2016) Libformat version 6.92, under Windows 7 64 bit.

Using F2 to rename a file can cause the file to have a filename too long so it can't be accessed. This bug has two possible outcomes.

As you might already know, under Windows the complete path to a file must be under MAX_PATH which currently is 260 characters. That includes drive letter, all folders and slash separators, and the file's name and extension (unlike in old 8.3 fashion, period does count too). Usually you shouldn't be able to deal with files longer than this limit, unless you're using certain API functions which it seems you do. However, these functions aren't used consistently across all the libraries used by XMP, and outside XMP it's kind of rare. The normal way to find this problem is moving a folder which has a file near the limit inside a folder which with its combined name length causes the file to exceed the limit. Without special software you can't access these files, but you can always move to root the folder which has the file for a simple rename (or from now on, use XMP).

In the case of XMP, you can rename directly a file so it's complete path is longer than the limit. This can happen in two ways. First, we can try to rename to a filename with extension which is longer than the limit. In such case, XMP shows the overwriting file panel, without any file information, not knowing to do with such a long filename.

And second, we can rename a file with a name shorter than the limit, but still with complete path longer than the limit. So if the name is 240 characters long, and it's inside a 10 character long folder, and when renaming we add 15 chars more, XMP will happily rename it, and read the thumbnail, but you will not be able to see the image (neither trying to launch it from the browser, which shows a blank screen, nor from outside XMP, which shows a 'file not found' error from XMP. However with XMP you can rename the file back to shorter than the limit.

My suggestion is that while renaming a file, each time the text changes, you calculate the complete path length and if it's larger than MAX_PATH, crop the last chars of the name (without touching the extension) so it is still accessable both to XMP and to any other program without giving problems. You could even add an option to specify how many 'safe characters' are between the limit and the maximum length that XMP will allow to rename.

I haven't tested with the autorenamer since I use another specific tool for that and I'm not familiar with yours. I'd also check name and path length limits for the other OS XMP is released for.

Regards, JMM.

User avatar
helmut
Posts: 8116
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: 0.83: XnView MP can rename files to too long names

Postby helmut » Sat Feb 11, 2017 9:39 pm

JMM72 wrote:First, we can try to rename to a filename with extension which is longer than the limit. In such case, XMP shows the overwriting file panel, without any file information, not knowing to do with such a long filename.

I could reproduce this problem by renaming an image file to this:
"My Image with 265 charachter filename 901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.jpg" :bugconfirmed:

JMM72 wrote:And second, we can rename a file with a name shorter than the limit, but still with complete path longer than the limit. So if the name is 240 characters long, and it's inside a 10 character long folder, and when renaming we add 15 chars more, XMP will happily rename it, and read the thumbnail, but you will not be able to see the image (neither trying to launch it from the browser, which shows a blank screen, nor from outside XMP, which shows a 'file not found' error from XMP. However with XMP you can rename the file back to shorter than the limit.
Also confirmed. :bugconfirmed: (I removed some characters from my filename above).

Tobby8714
Posts: 1
Joined: Fri May 19, 2017 4:12 pm

Re: 0.83: XnView MP can rename files to too long names

Postby Tobby8714 » Fri May 19, 2017 4:14 pm

Try with the long path tool. I used it for similar but not the exact problem and it worked. It was related to a long path file deletion problem.


Return to “Reproduced”

Who is online

Users browsing this forum: No registered users and 1 guest