Skip to content

馃悰 Abort entry parsing on a dangling field key before } - #602

Merged
MiWeiss merged 1 commit into
mainfrom
fix/splitter-dangling-key
Sep 2, 2026
Merged

MiWeiss merged 1 commit into
mainfrom
fix/splitter-dangling-key

Conversation

@MiWeiss

@MiWeiss MiWeiss commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

_move_to_end_of_entry returns on } without checking the text back to the last comma, and the mark regex never matches bare identifiers. A dangling key is dropped silently.

>>> lib = bibtexparser.parse_string("@article{b, title={x}, year}")
>>> lib.entries[0].fields_dict.keys(), lib.failed_blocks
(dict_keys(['title']), [])   # `year` gone, nothing reported

Fix: treat } as end of entry only when the text back to key_start is whitespace (the legal trailing-comma form), else abort into a failed block.

The branch that pushes a closing brace back now also advances key_start; without that a normal @article{a, title={x}} would falsely abort.

Tests: dangling key in three positions, plus six legal forms pinned. Suite 2609 passed, from 2576.


馃 Generated with Claude Code

@MiWeiss
MiWeiss force-pushed the fix/splitter-dangling-key branch 3 times, most recently from 54b3c74 to 30365a9 Compare September 2, 2026 20:00
`Splitter._move_to_end_of_entry` returned as soon as it saw a `}`, without
looking at the text between the last comma and that bracket. Since the mark
regex never matches bare identifiers, a key without `=` and value (e.g.
`@article{a, title={x}, year}`) was silently swallowed: the entry was reported
as clean and the token vanished.

A `}` now only ends the entry if nothing but whitespace precedes it (the legal
trailing-comma form); otherwise a BlockAbortedException is raised, so the entry
lands in `library.failed_blocks` with a warning, as for all other syntax errors.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@MiWeiss

MiWeiss commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

lgtm

@MiWeiss
MiWeiss merged commit b9d9023 into main Sep 2, 2026
31 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.

1 participant