keeweb / kdbxweb

Web Kdbx library
https://app.keeweb.info
MIT License
413 stars 57 forks source link

Group tags issue #53

Open mstoecklein opened 1 year ago

mstoecklein commented 1 year ago

Hello,

I am using the latest version 2.1.1. At first I thought I did something wrong, but after doing a separate test it seems like a bug in the save function. Group tags are not written into the output file.

import {default as kdbxweb} from 'kdbxweb';
import { writeFileSync } from 'fs';

const credentials = new kdbxweb.Credentials(kdbxweb.ProtectedValue.fromString('test'));

const db = kdbxweb.Kdbx.create(credentials, 'title');

const group = db.createGroup(db.getDefaultGroup(), 'Tagged Group');
// will not be saved in groups
group.tags = ['tag1', 'tag2'];

const entry = db.createEntry(group, 'Tagged Entry');
// will be saved in entries
entry.tags = ['tag1', 'tag2'];

const data = await db.saveXml();
writeFileSync('test.xml', data);

Here is the XML output of the KDBX file I get:

https://gist.github.com/mstoecklein/e2686de4c22a263240e75db6745df6ac

luckyrat commented 8 months ago

new databases default to kdbx v4.0 and no automatic upgrade to v4.1 occurs when you use v4.1 features.

Thus, you should be able to fix a problem like this by setting the header minor version to 1 after creation:

db.header.versionMinor = 0;