Closed ajtucker closed 2 weeks ago
It looks as though checkValidLocalname()
doesn't quite match the production for PN_LOCAL, in that the first character of the local name is restricted to:
PN_CHARS_U | ':' | [0-9] | PLX
while the rest are allowed to be:
Adding the following test fails:
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TestSerialization.java b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TestSerialization.java
index 08c3fd708f..6efb1eaef4 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TestSerialization.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TestSerialization.java
@@ -118,6 +118,9 @@ public class TestSerialization
@Test public void test_PName_Bad_7()
{ fmtURI_Prefix("http://example/x.", "<http://example/x.>", pmap1) ; }
+ @Test public void test_PName_Bad_8()
+ { fmtURI_Prefix("http://default/-x", "<http://default/-x>", pmap1) ; }
+
// Dots
@Test public void test_Dots_1() // Internal DOT
{ fmtURI_Prefix("http://example/x#a.b", "ex:a.b", pmap1) ; }
Version
5.0.0
What happened?
We're building a SPARQL query programatically and then serializing the query to a string to be able to run it against a Fuseki SPARQL endpoint. In one case, we build a query with a valid URI node that is then serialized as an invalid prefixed name, because the local part starts with an invalid character according to https://www.w3.org/TR/sparql11-query/#rPN_LOCAL
This query exhibits the issue:
Using
qparse
to parse the above throws aQueryParseException
as below when it checks the output query by re-parsing it.Relevant output and stacktrace
Are you interested in making a pull request?
Yes