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

Add tests for SPARQL syntax codepoint escapes and invalid codepoint use #67

Merged
merged 4 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s <http://a.example/p1> '€߿ࠀ࿿က쿿퀀퟿�𐀀𿿽񀀀󿿽􀀀􏿽'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s <http://a.example/p1> '\u0080\u07FF\u0800\u0FFF\u1000\uCFFF\uD000\uD7FF\uE000\uFFFD\U00010000\U0003FFFD\U00040000\U000FFFFD\U00100000\U0010FFFD'
}
54 changes: 53 additions & 1 deletion sparql11/data-sparql11/syntax-query/manifest.ttl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@prefix : <http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix mfx: <http://jena.hpl.hp.com/2005/05/test-manifest-extra#> .
@prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
Expand Down Expand Up @@ -103,6 +103,15 @@
:test_pn_bad_13

:test_pp_coll

:test_codepoint_escape_01
:test_codepoint_escape_02
:test_codepoint_escape_03
:test_codepoint_escape_bad_04
:test_codepoint_escape_bad_05
:test_codepoint_boundaries_01
:test_codepoint_boundaries_01_escaped
:test_invalid_codepoint_escaped_bad_01
) .

:test_1 rdf:type mf:PositiveSyntaxTest11 ;
Expand Down Expand Up @@ -622,3 +631,46 @@
dawgt:approvedBy <http://www.w3.org/2009/sparql/meeting/2012-08-07#resolution_2> ;
mf:name "syn-pp-in-collection" ;
mf:action <syn-pp-in-collection.rq> ;.

:test_codepoint_escape_01 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "\\U unicode codepoint escaping in literal" ;
mf:action <syn-codepoint-escape-01.rq> ;.

:test_codepoint_escape_02 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "\\U unicode codepoint escaping in query syntax" ;
mf:action <syn-codepoint-escape-02.rq> ;.

:test_codepoint_escape_03 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "\\U and \\u unicode codepoint escaping in variable name" ;
mf:action <syn-codepoint-escape-03.rq> ;.

:test_codepoint_escape_bad_04 rdf:type mf:NegativeSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "Invalid multi-pass codepoint escaping (\\u then \\U)" ;
mf:description "Unescaping one escape sequence must not produce content that is used in another escape sequence" ;
mf:action <syn-codepoint-escape-bad-04.rq> ;.

:test_codepoint_escape_bad_05 rdf:type mf:NegativeSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "Invalid multi-pass codepoint escaping (\\U then \\u)" ;
mf:description "Unescaping one escape sequence must not produce content that is used in another escape sequence" ;
mf:action <syn-codepoint-escape-bad-05.rq> ;.

:test_codepoint_boundaries_01 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "utf8 literal using codepoints at notable unicode boundaries" ;
mf:action <1val1STRING_LITERAL1_with_UTF8_boundaries.rq> ;.

:test_codepoint_boundaries_01_escaped rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "\\U and \\u unicode codepoint escaping in literal using codepoints at notable unicode boundaries" ;
mf:action <1val1STRING_LITERAL1_with_UTF8_boundaries_escaped.rq> ;.

:test_invalid_codepoint_escaped_bad_01 rdf:type mf:NegativeSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "\\u unicode codepoint escaping in literal using partial surrogate pair" ;
mf:description "Using a codepoint that is half of a surrogate pair (in the range U+D800–U+DFFF) without a corresponding codepoint is illegal" ;
mf:action <syn-invalid-codepoint-escaped-bad-01.rq> ;.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p "\U0001f46a" .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT \U0000002A WHERE \U0000007B # SELECT * WHERE {
?s ?p true .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s \u0024\U00000070 true . # ?s $p true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT * WHERE {
?s ?p \u005cU00000031 .
}

# the first escape here produces '\' REVERSE SOLIDUS (U+5C)
# its unescaping must not lead to a subsequent unescaping of "\U00000031" escape.
# This should cause a syntax error as "?s ?p \U00000031" and NOT a valid query as "?s ?p 1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT * WHERE {
?s ?p \U0000005cu0031 .
}

# the first escape here produces '\' REVERSE SOLIDUS (U+5C)
# its unescaping must not lead to a subsequent unescaping of "\u0031" escape.
# This should cause a syntax error as "?s ?p \u0031" and NOT a valid query as "?s ?p 1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s <http://a.example/p1> '\uD800'
}