jorabin / KeePassJava2

Java API for KeePass Password Databases - Read/Write 2.x (File versions 3 and 4), Read 1.x
Apache License 2.0
250 stars 71 forks source link

Custom icons cause problems #33

Closed schulbus13 closed 1 year ago

schulbus13 commented 2 years ago

I was given a manually created kdbx file containing a few custom icons. If I load (and edit, but thats not yet relevant) and save the database with KeePassJava2, the following problems occur, depending on the kind of database implementation I use:

SimpleDatabase

SimpleDatabase.load(creds, input).save(creds, output);

The following error is thrown

org.simpleframework.xml.core.ElementException: Element 'CustomIconUUID' does not have a match in class org.linguafranca.pwdb.kdbx.simple.SimpleGroup at line 341

JaxbDatabase

JaxbDatabase.load(creds, input).save(creds, output);

No error is thrown, but the custom icons are replaced with default blue folder icon (48). Also the entire file is skipped when I try to search something via the desktop application (Searching entries in this group: Disabled), which wasn't the case before.

DomDatabaseWrapper

DomDatabaseWrapper.load(creds, input).save(creds, output)

Custom icons are still there and I can also still search via the desktop application, but the loading and saving takes a very long time (a couple of minutes for a ~200kB file).

Is there a way to preserve the custom icons and the searchability while using one of the faster database implementations?

jorabin commented 2 years ago

The Dom implementation intentionally leaves things as it finds them, but as you say at a cost of speed. For the other two it looks like there is a mapping missing.

jorabin commented 1 year ago

I have been looking at this and as mentioned custom icons are mapped incorrectly, which affects both Jaxb and Simple.

I have reproduced and fixed the crash on load of custom icons in Simple.

I think that the problem with Jaxb losing the icon is probably because it saves custom icons incorrectly because of the incorrect mapping. I don't understand why icon 48 is chosen, but that's perhaps not really significant.

All of this is being done in the context of checking the operation of V4 file format which requires some more work.

jorabin commented 1 year ago

Closed in 2.2.1