diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index 0f166b6..139f719 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -597,6 +597,20 @@ class BTBTest extends PHPUnit_Framework_TestCase { $first_entry->removeField('author'); $this->assertFalse($first_entry->hasField('author')); } + + function testdefaultkey() { + bibtexbrowser_configure('BIBTEXBROWSER_BIBTEX_VIEW', 'original'); + $bibtex = "@article{title={An article Book},author = {Martin Monperrus and Foo Ac\'e and Monperrus, Martin}}"; + $key = md5($bibtex); + $test_data = fopen('php://memory','x+'); + fwrite($test_data, $bibtex); + fseek($test_data,0); + $db = new BibDataBase(); + $db->update_internal("inline", $test_data); + $entry=$db->getEntryByKey($key); + $this->assertEquals($bibtex, $entry->getText()); + } + } // end class diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 36f4239..5ac1abd 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -911,7 +911,7 @@ class BibDBBuilder extends ParserDelegate { // we add a key if there is no key if (!$this->currentEntry->hasField(Q_KEY) && $this->currentEntry->getType()!='string') { - $this->currentEntry->setField(Q_KEY,md5($this->currentEntry->getTitle().implode('',$this->currentEntry->getRawAuthors()))); + $this->currentEntry->setField(Q_KEY,md5($entrysource)); } // we set the fulltext