Page 1 of 1

Fixed: Single-quote in filename .ini recent history bug

Posted: 09 Nov 2011 21:56
by Fish
HxD 1.7.7.0

The .INI file does not properly support filenames with single quotes.

Example:

Create a folder called "C:\a".

Within this folder create three files named 111.txt, 222.txt and '333'.txt.

(Note how the third filename has single quotes (apostrophes) within its name)

View the files with HxD in the following(*) illustrative sequence:
  1. 111
    222
    222
    111
    222
    '333'
    '333'
    111
    111
    222
    111
    111
    111
Each time you view the next file, examine the contents of the HxD .ini file (kept in "C:\Users\<name>\AppData\Roaming\Mael\HxD" directory) after each step. You should see the "Item2" line in the "[\HistoryLists\RecentFiles\]" section grow longer and longer and longer, e.g.:

Code: Select all

[\HistoryLists\RecentFiles\]
Count=3
Item0=C:\a\111.txt
Item1=C:\a\222.txt
Item2="'C:\a\222.txtC:\a\222.txtC:\a\111.txtC:\a\111.txtC:\a\111.txtC:\a\'#39'333'#39'.txt'"
Once the line grows beyond the (program? system?) limit (32K? 64K?), HxD begins looping, consuming 100% CPU, for several MINUTES before the requested file is finally opened. :(

The bug is likely related to how filenames with single quotes (apostrohes) are encoded. As you can see, the entry is not encoded properly:

Code: Select all

   Item0="'C:\a\'#39'333'#39'.txt'"
It SHOULD be simply:

Code: Select all

   Item0=C:\a\'333'.txt
In addition to the improper encoding bug, there is another (related?) bug wherein the previous entry's filename is inserted at the beginning of the last entry's filename (see Item2 further above) which exacerbates the problem.

Regardless, the serious nature of the bug is that, after a long time, when you least expect it, HxD will cease functioning altogether once the line grows beyond some unknown limit. I'm guess either it, or Windows, it trying to build/create a Menu entry with a very, very, very, very ... long name, and that is why the CPU goes to 100% and stays there for a very long time (until you kill it using task manager).

It's easy to fix once you know what's causing it (simply edit the .ini and delete the entire "[\HistoryLists\RecentFiles\]" section).

But this bug is NOT obvious, and when it occurs, it appears as if HxD is broken (and what is worse, un-installing and re-installing it does NOT fix the problem! The uninstaller does not remove the .ini files!), leading to confusion, frustration, and eventually great concern. (I myself ended up restoring my entire system from backup the first time this happened because I could not figure out what was causing it.)

Other than the above bug however, I firmly believe HxD to be a very, VERY nice program! :)

Thank you Mael for writing it and continuing to offer it for free! :D

----------
(*) You do not have to view the files in that exact sequence. That is simply the sequence I used to illustrate the problem.

Re: Single-quote in filename .ini recent history bug

Posted: 11 Nov 2011 19:02
by Maël
Hi Fish,
Thanks for writing a good bug report!

I could reproduce the string-appending issue and fixed it. The encoding itself is not buggy though: #39 means character 39 and represents the character '. The weird looking string is due to an escaping of special characters, were ' is used as a marker denoting escaping starts, so it looks a little redundant but it isn't (It's similar to \\ in C when meaning \). The issue was due to an uninitialized return value in a function such that a string was appended to a string that should have been empty but was still containing the result of a previous call. This non-empty string issue happened due to an unexpected compiler optimization.

Could you check this development version of HxD to see if it fixes the issue for you, too? (it should work when starting from a valid ini file):
http://mh-nexus.de/HxD.zip

Re: Single-quote in filename .ini recent history bug

Posted: 12 Nov 2011 04:22
by Fish
Hi Maël!

Wow. That was quick. :)

I appreciate the offer to try your development version but unfortunately the URL you provided does not work for me.

I keep getting 404 Not Found. :(

Perhaps you simply mistyped it?

In case you did not however, you could upload it to my FTP site's "incoming"(*) folder at:

ftp://www.softdevlabs.com/fish/incoming/

whre I could then simply download it from.

Thanks again for everything you do, Maël! You write very nice software! :D

--------------------
(*) Note: after uploading it you will not be able to "see" it. The incoming folder is write-only. You will not be able to view the folder's contents or download anything from the incoming folder. You can only download from the 'pub' folder which is read-only. This is standard industry practice to prevent your site from being used to distribute "warez".

Re: Single-quote in filename .ini recent history bug

Posted: 12 Nov 2011 11:41
by Maël
I am sorry, it was in the wrong directory on my website. Now it should work, please try again :) Best is to use a download manager like DownThemAll, because sometimes the server interrupts downloads.

Re: Single-quote in filename .ini recent history bug

Posted: 12 Nov 2011 22:46
by Fish
Thank you. I was able to download it.

Unfortunately it is a non-English version and I only speak English, so I do not know how to use it.

Can you build me an English version to try?

Thanks!

Re: Single-quote in filename .ini recent history bug

Posted: 13 Nov 2011 01:42
by Maël
Unfortunately, it's quite a lengthy process to translate HxD. But the file menu is ordered the same way regardless of language (so the old HxD version can give you hints on what is where). But actually there are only a few relevant words: "File" is called "Datei" and "recent files" is called "Zuletzt geöffnete Dateien". "Open" is "Öffnen".

It's just for quick testing if the bug is gone, not for production use. Thanks for trying.

Re: Single-quote in filename .ini recent history bug

Posted: 15 Nov 2011 15:58
by DVV
Hi, just tried the developing version - looks very promising! A comment regarding the Data Inspector: I think it will be worth to add an option "Show HEX values" for Byte/Word/DWord/etc.

Re: Single-quote in filename .ini recent history bug

Posted: 24 Oct 2017 21:14
by Maël
Fixed in 2.0 RC, which is also available in English (this is a multi-lang setup):
https://mh-nexus.de/downloads/HxDSetup.zip

Re: Single-quote in filename .ini recent history bug

Posted: 24 Oct 2017 21:16
by Maël
DVV wrote: 15 Nov 2011 15:58I think it will be worth to add an option "Show HEX values" for Byte/Word/DWord/etc.
Also done in 2.0 RC.