Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/51 dot last char #60

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Parser/Turtle.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,10 @@ protected function parseQNameOrBoolean()

// Last char of name must not be a dot
if (mb_substr($localName, -1) === '.') {
throw new Exception("Turtle Parse Error: last character of QName must not be a dot", $this->line, $this->column - 1);
$localName = substr_replace($localName, '', -1);
$this->unread($c); // step back
$this->unread('.'); // return dot to input buffer
$c = $this->read(); // read, because below the unread($c) is done for all cases
}
}

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/turtle/gh51-sweetrdf-dot-in-name.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<http://example.org/#Subject.WithADot> <http://example.org/#predicate.withADot> <http://example.org/#Object.WithADot> .
<http://example.org/#Subject.With.Dots> <http://example.org/#predicate.with.dots> <http://example.org/#Object.With.Dots> .
<http://example.org/#sub> <http://example.org/#pred> <http://example.org/#Object.WithADot> .
3 changes: 3 additions & 0 deletions test/fixtures/turtle/gh51-sweetrdf-dot-in-name.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
# See https://github.com/sweetrdf/easyrdf/issues/51
:Subject.WithADot :predicate.withADot :Object.WithADot .
:Subject.With.Dots :predicate.with.dots :Object.With.Dots .

# A dot as last char is not part of the name but parsed as statement ending
:sub :pred :Object.WithADot.
2 changes: 1 addition & 1 deletion tests/EasyRdf/Parser/TurtleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public function testIssue51Bad()
// Test long literals with missing end
$this->expectException('EasyRdf\Parser\Exception');
$this->expectExceptionMessage(
'Turtle Parse Error: last character of QName must not be a dot on line 7, column 20'
'Turtle Parse Error: Illegal predicate type: literal on line 7, column 19'
);
$this->parseTurtle('turtle/gh51-sweetrdf-dot-in-name-bad.ttl');
}
Expand Down
Loading