Skip to content

Commit b55db9e

Browse files
committed
Add syntax tests for codepoint escaping.
1 parent 22ba727 commit b55db9e

File tree

10 files changed

+116
-0
lines changed

10 files changed

+116
-0
lines changed

sparql/sparql12/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ trs:manifest rdf:type mf:Manifest ;
3333
""";
3434
mf:include (
3535
<grouping/manifest.ttl>
36+
<syntax-escaping/manifest.ttl>
3637
<syntax-triple-terms-negative/manifest.ttl>
3738
<syntax-triple-terms-positive/manifest.ttl>
3839
<eval-triple-terms/manifest.ttl>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\u0041\u0053\u004B\u0020\u007B\u007D
2+
3+
# The query `ASK {}` entirely encoded using codepoint escapes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX ns: <http://example.org/>
2+
SELECT * WHERE {
3+
?s ?p ns:id\u005c=123
4+
}
5+
6+
# the escape here produces '\' REVERSE SOLIDUS (U+5C)
7+
# its unescaping must lead to a Prefixed Name ns:id\=123 using an escaped
8+
# equals sign (U+3D), representing the IRI <http://example.org/id=123>.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT * WHERE {
2+
?s ?p "\\u0074"
3+
}
4+
# Legal codepoint escape of LATIN SMALL LETTER T (U+74), resulting in a
5+
# valid backslash escape \t for CHARACTER TABULATION (U+9).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT * WHERE {
2+
?s ?p "\u005C\u005Cn"
3+
}
4+
# Two legal codepoint escapes of REVERSE SOLIDUS (U+5C), resulting in a
5+
# valid backslash escape \\ for REVERSE SOLIDUS (U+5C) followed by 'n'.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX og: <http://ogp.me/ns#>
2+
SELECT * WHERE {
3+
?page og:audio\u00253Atitle ?title
4+
}
5+
6+
# the escape here produces '%' PERCENT SIGN (U+25)
7+
# its unescaping must lead to a Prefixed Name og:audio%3Atitle which includes
8+
# the percent-encoding %3A (COLON).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT\u0020*\U00000009WHERE {
2+
?s ?p "value"
3+
}
4+
5+
# the escapes here produce whitespace -- SPACESPACE (U+20) and
6+
# CHARACTER TABULATION (U+9) -- surrounding the `*` token in the
7+
# SELECT projection.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT * WHERE {
2+
?s ?p \u0022value"
3+
}
4+
5+
# the escape here produces QUOTATION MARK (U+22)
6+
# its unescaping must lead to the literal 'value'.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT * WHERE {
2+
?s ?p "\\u0041"
3+
}
4+
# Legal codepoint escape of LATIN CAPITAL LETTER A (U+41), resulting in an
5+
# invalid backslash escape \A.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2+
@prefix : <https://w3c.github.io/rdf-tests/sparql/sparql12/escaping#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
5+
@prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
6+
@prefix dawgt: <http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#> .
7+
8+
:manifest rdf:type mf:Manifest ;
9+
rdfs:label "SPARQL Codepoint-Escaping Tests" ;
10+
mf:entries
11+
(
12+
:codepoint-esc-01
13+
:codepoint-esc-02
14+
:codepoint-esc-bad-03
15+
:codepoint-esc-04
16+
:codepoint-esc-05
17+
:codepoint-esc-06
18+
:codepoint-esc-07
19+
:codepoint-esc-08
20+
) .
21+
22+
23+
:codepoint-esc-01 rdf:type mf:PositiveSyntaxTest ;
24+
dawgt:approval dawgt:Proposed ;
25+
mf:name "codepoint-esc-01.rq" ;
26+
mf:action <codepoint-esc-01.rq> .
27+
28+
:codepoint-esc-02 rdf:type mf:PositiveSyntaxTest ;
29+
dawgt:approval dawgt:Proposed ;
30+
mf:name "codepoint-esc-02.rq" ;
31+
rdfs:comment "codepoint escape for the backslash of a PN_LOCAL_ESC in the PN_LOCAL part of a PrefixedName" ;
32+
mf:action <codepoint-esc-02.rq> .
33+
34+
:codepoint-esc-bad-03 rdf:type mf:NegativeSyntaxTest ;
35+
dawgt:approval dawgt:Proposed ;
36+
mf:name "codepoint-esc-bad-03.rq" ;
37+
rdfs:comment "codepoint escape that results in an invalid backslash escape (requires handling codepoint escaping before backslash escaping)" ;
38+
mf:action <codepoint-esc-bad-03.rq> .
39+
40+
:codepoint-esc-04 rdf:type mf:PositiveSyntaxTest ;
41+
dawgt:approval dawgt:Proposed ;
42+
mf:name "codepoint-esc-04.rq" ;
43+
rdfs:comment "codepoint escape that results in a valid backslash escape" ;
44+
mf:action <codepoint-esc-04.rq> .
45+
46+
:codepoint-esc-05 rdf:type mf:PositiveSyntaxTest ;
47+
dawgt:approval dawgt:Proposed ;
48+
mf:name "codepoint-esc-05.rq" ;
49+
mf:action <codepoint-esc-05.rq> .
50+
51+
:codepoint-esc-06 rdf:type mf:PositiveSyntaxTest ;
52+
dawgt:approval dawgt:Proposed ;
53+
mf:name "codepoint-esc-06.rq" ;
54+
rdfs:comment "codepoint escape for the percent sign in the PL_LOCAL part of a PrefixedName" ;
55+
mf:action <codepoint-esc-06.rq> .
56+
57+
:codepoint-esc-07 rdf:type mf:PositiveSyntaxTest ;
58+
dawgt:approval dawgt:Proposed ;
59+
mf:name "codepoint-esc-07.rq" ;
60+
rdfs:comment "codepoint escape for whitespace separating the projection tokens: SELECT * WHERE" ;
61+
mf:action <codepoint-esc-07.rq> .
62+
63+
:codepoint-esc-08 rdf:type mf:PositiveSyntaxTest ;
64+
dawgt:approval dawgt:Proposed ;
65+
mf:name "codepoint-esc-08.rq" ;
66+
rdfs:comment "codepoint escape for the starting double-quote of a literal" ;
67+
mf:action <codepoint-esc-08.rq> .
68+

0 commit comments

Comments
 (0)