Skip to content

Commit 68ee37e

Browse files
committed
Merge branch 'bug44-v2'
2 parents 49b46e0 + 63901fe commit 68ee37e

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private function readPostType($char)
243243
*/
244244
private function readTagName($char)
245245
{
246-
if (preg_match('/^[a-zA-Z0-9_\+:\-]$/', $char)) {
246+
if (preg_match('/^[a-zA-Z0-9_\+:\-\.\/]$/', $char)) {
247247
$this->appendToBuffer($char);
248248
} elseif ($this->isWhitespace($char) && empty($this->buffer)) {
249249
// Skips because we didn't start reading

tests/Parser/CitationKeyTest.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the BibTex Parser.
5+
*
6+
* (c) Renan de Lima Barbosa <renandelima@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace RenanBr\BibTexParser\Test\Parser;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use RenanBr\BibTexParser\Parser;
16+
use RenanBr\BibTexParser\Test\DummyListener;
17+
18+
/**
19+
* @covers \RenanBr\BibTexParser\Parser
20+
*/
21+
class CitationKeyTest extends TestCase
22+
{
23+
/**
24+
* @group regression
25+
* @group bug44
26+
*
27+
* @see https://github.com/renanbr/bibtex-parser/issues/44
28+
*/
29+
public function testDBLPCitationKey()
30+
{
31+
$listener = new DummyListener();
32+
33+
$parser = new Parser();
34+
$parser->addListener($listener);
35+
$parser->parseString('@Article{DBLP:journals/npl/CaamanoSBD16}');
36+
37+
// 0 -> type
38+
// 1 -> citation key
39+
// 2 -> original entry
40+
$this->assertCount(3, $listener->calls);
41+
list($text, $type) = $listener->calls[1];
42+
43+
$this->assertSame('DBLP:journals/npl/CaamanoSBD16', $text);
44+
$this->assertSame(Parser::CITATION_KEY, $type);
45+
}
46+
47+
/**
48+
* @group regression
49+
* @group bug44
50+
*
51+
* @see https://github.com/renanbr/bibtex-parser/issues/44
52+
*/
53+
public function testACMCitationKey()
54+
{
55+
$listener = new DummyListener();
56+
57+
$parser = new Parser();
58+
$parser->addListener($listener);
59+
$parser->parseString('@inproceedings{Kyriakakis:2016:EMI:3003733.3003777}');
60+
61+
// 0 -> type
62+
// 1 -> citation key
63+
// 2 -> original entry
64+
$this->assertCount(3, $listener->calls);
65+
list($text, $type) = $listener->calls[1];
66+
67+
$this->assertSame('Kyriakakis:2016:EMI:3003733.3003777', $text);
68+
$this->assertSame(Parser::CITATION_KEY, $type);
69+
}
70+
}

0 commit comments

Comments
 (0)