0.83: XnView MP can rename files to too long names

Older bugs which are supposed to be fixed in 0.84. *** Please try to reproduce your bug and confirm the bug fix. ***

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: 8120
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.

User avatar
xnview
Author of XnView
Posts: 28394
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

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

Postby xnview » Mon Jun 19, 2017 1:19 pm

O.k., thank you, I can also reproduce the problem. Issue 1268 is fixed in next version.
Pierre.

User avatar
xnview
Author of XnView
Posts: 28394
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

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

Postby xnview » Sat Jul 08, 2017 12:42 pm

This problem is supposed to be fixed in XnView MP 0.87. Please check and confirm the bug fix here.
Pierre.

HanVroon
Posts: 175
Joined: Thu Jan 28, 2010 7:30 am

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

Postby HanVroon » Fri Aug 04, 2017 11:38 am

Tested with 0.87 beta 2, not fixed.

Tested bij renaming a file with XnViewMP (F2) to something with <250 characters>.jpg, in a path of 15 characters.
I understood XnViewMP wasn't supposed to allow that anymore.

In version 0.86 the thumb of the long filename file isn't shown and the file cannot be opened.
In 0.87 the thumb is shown, but the file cannot be opened, message File can't be loaded.
In Windows Explorer the file cannot be deleted, not even renamed...

Only after renaming the file in XnViewMP, shortening it 20 characters, the file can be handled again.

In Windows Explorer, when typing a filename, the input just stops after the max amount of characters.
When pasting a too long name in the rename dialog, the string is truncated.

User avatar
xnview
Author of XnView
Posts: 28394
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

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

Postby xnview » Mon Aug 07, 2017 11:57 am

you are able to rename a full path to more than 260 chars???
Pierre.

HanVroon
Posts: 175
Joined: Thu Jan 28, 2010 7:30 am

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

Postby HanVroon » Fri Aug 18, 2017 8:22 am

Yes....

But it depends on how you test.
Because it it not easy to test by counting 250 keypresses or so, I used an editor and types a filename with 250 characters, looking at the column counter of the editor. Then I copy/pasted that 250 character string into the Rename dialog of XnViewMP.
If you start typing a long filename in the Rename dialog of XnViewMP, it's different.

So please test yourselves with the following procedures:

Still possible to rename:
Copy/paste a 250 character string into the Rename dialog of XnViewMP. The name is accepted, the file is renamed, but not accessible

Not possible to rename:
Copy/paste a 257 character string into the Rename dialog of XnViewMP. A message "An error occurs during rename!" appears.
SO: only the filename length is checked, NOT the complete path.

cday
XnThusiast
Posts: 1588
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

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

Postby cday » Fri Aug 18, 2017 8:52 am

Could you post test long filenames for Pierre to use?

You could if you wish edit the above post, either pasting in the long names (if that works satisfactorily) or attach a suitable file (a text file would have to be placed in a ZIP or similar archive, I think).

HanVroon
Posts: 175
Joined: Thu Jan 28, 2010 7:30 am

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

Postby HanVroon » Fri Aug 18, 2017 9:04 am

Of course I could, but I cannot imagine that just I can create the bug, because it's so obvious.

Just try it on a file that is located in a path with 10 characters in lengt or so, and pase a filename with 250 characters in it.

To help, here is a 250 character string:
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567890

Just paste that string above in the Rename dialog box and press OK.
The file s renamed, which shouldn't be possible.
The file cannot be opened with XnViewMP and not with Windows explorer.
Luckily it can be renamed back to something short with both applications to get access again.

Shnoober
Posts: 15
Joined: Sat Jan 03, 2015 11:32 am

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

Postby Shnoober » Thu Sep 07, 2017 1:09 pm

I hope this bug wasn't fixed in the linux version because linux can handle >260 character path names.

User avatar
xnview
Author of XnView
Posts: 28394
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

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

Postby xnview » Thu Sep 07, 2017 6:19 pm

Shnoober wrote:I hope this bug wasn't fixed in the linux version because linux can handle >260 character path names.

it was a fix for windows only
Pierre.

HanVroon
Posts: 175
Joined: Thu Jan 28, 2010 7:30 am

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

Postby HanVroon » Mon Sep 11, 2017 3:21 pm

Just form my "administration": Not yet fixed in 0.87 final.

HanVroon
Posts: 175
Joined: Thu Jan 28, 2010 7:30 am

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

Postby HanVroon » Wed Nov 22, 2017 5:05 pm

Not yet fixed in 0.88.

Tested again:
Used a directory D:\1234567890
Copied a file in that directory and started the rename process.

- A filename of more than 260 characters long cannot be entered in the File rename field.

- A filename of 260 characters can be entered, but when clicking OK, the message An error occurs during rename! appears.

- A filename of 252 can be entered and is accepted. This is the longest filename accepted by XnViewMP, no matter where the file is, so for example in the root. But in this example the file is in D:\1234567890 and it cannot be handled by Windows Explorer.
The total path:
D:\1234567890\1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 123456789.JPG

- Shortened the filename until it could be handled by Windows Explorer that was when the total path length was 260 characters, so the filename in this example was 242 characters.
The total path of the longest Windows-accepted filename:
D:\1234567890\1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890.JPG


Return to “Retest”

Who is online

Users browsing this forum: No registered users and 1 guest