Skip to content

Commit

Permalink
Issue/52 whitespace before langtag (#56)
Browse files Browse the repository at this point in the history
* Fix issue with whitespace in turtle parser: Allow whitespace between quoted string literal and langtag or datatype
* Add testcase for whitespace between string literal and datatype iri

---------

Co-authored-by: Konrad Abicht <hi@inspirito.de>
  • Loading branch information
Michiel-s and k00ni authored Jan 18, 2025
1 parent 0aa3272 commit c573f61
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Parser/Turtle.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ protected function parseQuotedLiteral()
{
$label = $this->parseQuotedString();

$this->skipWSC();

// Check for presence of a language tag or datatype
$c = $this->peek();

Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/turtle/gh52-sweetrdf-whitespace-langtag.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<http://example.org/#a> <http://www.w3.org/2000/01/rdf-schema#label> "Test"@en .
<http://example.org/#a> <http://www.w3.org/2000/01/rdf-schema#label> "Test"^^<http://www.w3.org/2001/XMLSchema#string> .
9 changes: 9 additions & 0 deletions test/fixtures/turtle/gh52-sweetrdf-whitespace-langtag.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/#> .

# Allow whitespace between literal and language tag
:a rdfs:label "Test" @en .

# Allow whitespace between literal and datatype IRI
:a rdfs:label "Test" ^^xs:string .
13 changes: 12 additions & 1 deletion tests/EasyRdf/Parser/TurtleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,9 @@ public function testIssue140()
}

/**
* Allow usage of dot in middle of name
*
* @see https://github.com/sweetrdf/easyrdf/issues/51
* Notice this is an issue reported in the sweetrdf/easyrdf fork
*/
public function testIssue51()
{
Expand All @@ -597,4 +598,14 @@ public function testIssue51Bad()
);
$this->parseTurtle('turtle/gh51-sweetrdf-dot-in-name-bad.ttl');
}

/**
* Allow whitespace(s) between quoted string literal and langtag or datatype
*
* @see https://github.com/sweetrdf/easyrdf/issues/52
*/
public function testIssue52()
{
$this->turtleTestCase('gh52-sweetrdf-whitespace-langtag');
}
}

0 comments on commit c573f61

Please sign in to comment.