Skip to content

db: accept a UTF-8 BOM at the start of db.txt - #1357

Merged
ajeetdsouza merged 3 commits into
ajeetdsouza:mainfrom
b84330808:fix-db-utf8-bom
Nov 7, 2026
Merged

ajeetdsouza merged 3 commits into
ajeetdsouza:mainfrom
b84330808:fix-db-utf8-bom

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

The new plaintext db.txt is meant to be editable by hand, but if it gets saved with a UTF-8 byte order mark, zoxide can't open it anymore. Windows PowerShell 5.1's Set-Content -Encoding utf8 writes one, and so does Notepad's "UTF-8 with BOM":

zoxide: could not parse database: C:\Users\me\AppData\Local\zoxide\db.txt

Caused by:
    line 1: could not parse timestamp: 1793550000: invalid digit found in string

The BOM is invisible, so the timestamp in the message looks fine. Since z and the prompt hook both open the database, zoxide stays broken until the file is fixed by hand.

This strips a leading BOM before parsing, like the trailing \r that's already ignored for CRLF files. The next save writes the file without it. Added a test that opens a db.txt starting with a BOM.

I used Claude Code to write this change.

@ajeetdsouza

Copy link
Copy Markdown
Owner

Thanks!

@ajeetdsouza
ajeetdsouza merged commit c21f547 into ajeetdsouza:main Nov 7, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants