From 3175cd2c09cc56995d1880055c859adab844ff3e Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Mon, 3 Sep 2018 20:32:10 +0200 Subject: [PATCH] fix a bug when splitting author list --- bibacid-utf8.bib | 12 ++++++++++++ bibtexbrowser-test.php | 11 +++++++++++ bibtexbrowser.php | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bibacid-utf8.bib b/bibacid-utf8.bib index 1c04146..41bb533 100755 --- a/bibacid-utf8.bib +++ b/bibacid-utf8.bib @@ -229,3 +229,15 @@ MRREVIEWER = {Jean-Fran{\c{c}}ois Clouet}, author = "Foo Bar", year = 2017 } + +@techreport{arXiv-1807.05030, + author = {Oscar Luis Vera{-}P{\'{e}}rez and + Benjamin Danglot and + Martin Monperrus and + Benoit Baudry}, + title = {A Comprehensive Study of Pseudo-tested Methods}, + year = {2018}, + number = {1807.05030}, + institution = {arXiv}, + url = {http://arxiv.org/pdf/1807.05030}, +} diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index 0d1a07a..be4d567 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -653,6 +653,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { function test_identity() { $btb = new BibDataBase(); $btb->load('bibacid-utf8.bib'); + bibtexbrowser_configure('BIBTEXBROWSER_BIBTEX_VIEW_FILTEREDOUT', ''); // computing the representation $d = new SimpleDisplay(); @@ -663,6 +664,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { $nref = count($btb->bibdb); $bibtex = $btb->toBibtex(); + // reparsing the new content $btb2 = $this->_createDB($bibtex, 'bibacid-utf8.bib'); $d->setDB($btb2); @@ -750,6 +752,15 @@ class BTBTest extends PHPUnit_Framework_TestCase { $this->assertEquals("[1]", $db->getEntryByKey('key2')->getAbbrv()); } + function test_bug_201808() { + $btb = new BibDataBase(); + $btb->load('bibacid-utf8.bib'); + $this->assertEquals(4,count($btb->bibdb['arXiv-1807.05030']->getRawAuthors())); + $this->assertEquals(4,count($btb->bibdb['arXiv-1807.05030']->getFormattedAuthorsArray())); + $this->assertEquals("Oscar Luis Vera-Pérez, Benjamin Danglot, Martin Monperrus and Benoit Baudry",$btb->bibdb['arXiv-1807.05030']->getAuthor()); + } + + } // end class @copy('bibtexbrowser.local.php.bak','bibtexbrowser.local.php'); diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 89e4cdf..fc3c999 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -1394,7 +1394,7 @@ class BibEntry { * return a string 'Unknown'. */ function getAuthor() { if (array_key_exists(AUTHOR, $this->fields)) { - return getFormattedAuthorsString(); + return $this->getFormattedAuthorsString(); } // 2010-03-02: commented the following, it results in misleading author lists // issue found by Alan P. Sexton @@ -1444,7 +1444,7 @@ class BibEntry { } function split_authors() { - $array = preg_split('/ and /i', @$this->raw_fields[Q_AUTHOR]); + $array = preg_split('/ and( |$)/ims', @$this->raw_fields[Q_AUTHOR]); $res = array(); // we merge the remaining ones for ($i=0; $i < count($array)-1; $i++) {