Merge pull request #253 from pubs/fix/252

Fix collision of entry type key with valid field name 'type'.
This commit is contained in:
Olivier Mangin 2021-01-19 21:33:47 -08:00 committed by GitHub
commit 60b424a745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -7,7 +7,7 @@ from .p3 import ustr, uchr
# Citekey stuff
TYPE_KEY = 'type'
TYPE_KEY = 'ENTRYTYPE'
CONTROL_CHARS = ''.join(map(uchr, list(range(0, 32)) + list(range(127, 160))))
CITEKEY_FORBIDDEN_CHARS = '@\'\\,#}{~%/ ' # '/' is OK for bibtex but forbidden

View File

@ -57,6 +57,12 @@ class TestEnDecode(unittest.TestCase):
self.assertEqual(bibraw1, bibraw2)
def test_decode_bibtex_preserves_type_field(self):
"""Test that multiple encode/decode step preserve data"""
decoder = endecoder.EnDecoder()
entry = decoder.decode_bibdata(bibtex_raw0)
self.assertEqual(entry['Page99']['type'], "technical report")
def test_endecode_bibtex_BOM(self):
"""Test that bibtexparser if fine with BOM-prefixed data"""
decoder = endecoder.EnDecoder()