icon_data corruption in windows_open_with.json

Bug #1900299 reported by ownedbycats
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

This is only a problem because I was tampering with the user data files (trying to rename the open with programs) - but documenting it in case similar issues come up.

Steps to replicate:

1. Add a new program to Calibre's Open With. I used Paint.NET but other programs cause the issue too. Adding an icon to an existing entry doesn't produce this issue.
2. Exit Calibre.
3. Open windows_open_with.json in Notepad++ (my usual text editor, Notepad2, just crashed). Make sure a garbled-looking icon_data entry is in the json. Immediately close the file without modifying or saving it.
4. Open Calibre again.
5. Right-click on the cover in the book info pane/window. It throws this error:

calibre, version 5.3.0
ERROR: Unhandled exception: <b>TypeError</b>:string argument without an encoding

calibre 5.3 [64bit] embedded-python: True is64bit: True
Windows-10-10.0.19041-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19041')
Python 3.8.5
Windows: ('10', '10.0.19041', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: Barnes & Noble (1, 2, 16) && Calibre Power Search Plugin (1, 6, 0) && Clean Comments (0, 1, 0) && Comments Cleaner (1, 2, 1) && Count Pages (1, 10, 0) && Drop Search Results (1, 0, 10) && Embed Comic Metadata (1, 5, 0) && EpubCheck (0, 2, 3) && EpubMerge (2, 11, 0) && Extract ISBN (1, 5, 0) && FanFicFare (3, 24, 1) && Fantastic Fiction (1, 4, 0) && Favourites Menu (1, 0, 5) && Find Duplicates (1, 8, 1) && Generate Cover (1, 5, 25) && Goodreads (1, 5, 1) && Import List (1, 5, 1) && Job Spy (1, 0, 186) && Kindle hi-res covers (0, 5, 0) && Kobo Books (1, 8, 0) && Kobo Utilities (2, 11, 8) && KoboTouchExtended (3, 4, 1) && Library Codes (1, 0, 47) && Manage Series (1, 2, 11) && Modify ePub (1, 6, 1) && MultiColumnSearch (1, 0, 84) && Open With (1, 5, 12) && Quality Check (1, 10, 1) && Reading List (1, 6, 17) && Save To Format (0, 0, 6) && SmartEject (2, 3, 0) && View Manager (1, 5, 7)
Traceback (most recent call last):
  File "calibre\gui2\book_details.py", line 472, in contextMenuEvent
  File "calibre\gui2\book_details.py", line 339, in create_open_cover_with_menu
  File "calibre\gui2\open_with.py", line 349, in populate_menu
  File "calibre\gui2\open_with.py", line 62, in entry_to_icon_text
TypeError: string argument without an encoding

I was able to fix it by exiting Calibre, opening the file again in Notepad++, and carefully removing the corrupted icon_data from the json.

Also, I noticed that adding an icon manually doesn't produce a garbled entry - adding the icon manually only allows image files, so I suspect it may be due to getting the icon from the application binaries.

I've attached a json file with corrupted icon_data in Paint.NET. It also has a well-formed icon_data (for the Calibre 3 viewer) for comparison.

Revision history for this message
ownedbycats (ownedbycats) wrote :
Revision history for this message
ownedbycats (ownedbycats) wrote :

While I'm here, an in-program way to be able to edit the "open with" program names would be nice :)

description: updated
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
Revision history for this message
ownedbycats (ownedbycats) wrote :

That was fast!

description: updated
description: updated
Revision history for this message
ownedbycats (ownedbycats) wrote :

This bug still seems to be present in 5.4.2. I added 7-Zip File Manager to the list of Open With applications for some formats and it appeared as garbage data in windows_open_with.json.

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1900299

That's not garbage data, thats base64 encoded data.

Revision history for this message
Eli Schwartz (eschwartz) wrote : Re: [Bug 1900299] Re: calibre bug 1900299

The bug was:

ERROR: Unhandled exception: <b>TypeError</b>:string argument without an
encoding

This should have been fixed...

Revision history for this message
ownedbycats (ownedbycats) wrote :

Ok that makes sense. I just thought it was bad data because Notepad2 can't handle it and either freezes indefinitely/crashes. (embarrassment smiley here)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.