Skip to content

Add syntax tests for codepoint escaping. #151

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions sparql/sparql12/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ trs:manifest rdf:type mf:Manifest ;
""";
mf:include (
<grouping/manifest.ttl>
<syntax-escaping/manifest.ttl>
<syntax-triple-terms-negative/manifest.ttl>
<syntax-triple-terms-positive/manifest.ttl>
<eval-triple-terms/manifest.ttl>
Expand Down
3 changes: 3 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-01.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\u0041\u0053\u004B\u0020\u007B\u007D

# The query `ASK {}` entirely encoded using codepoint escapes.
8 changes: 8 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-02.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX ns: <http://example.org/>
SELECT * WHERE {
?s ?p ns:id\u005c=123
}

# the escape here produces '\' REVERSE SOLIDUS (U+5C)
# its unescaping must lead to a Prefixed Name ns:id\=123 using an escaped
# equals sign (U+3D), representing the IRI <http://example.org/id=123>.
5 changes: 5 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-04.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s ?p "\\u0074"
}
# Legal codepoint escape of LATIN SMALL LETTER T (U+74), resulting in a
# valid backslash escape \t for CHARACTER TABULATION (U+9).
5 changes: 5 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-05.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s ?p "\u005C\u005Cn"
}
# Two legal codepoint escapes of REVERSE SOLIDUS (U+5C), resulting in a
# valid backslash escape \\ for REVERSE SOLIDUS (U+5C) followed by 'n'.
8 changes: 8 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-06.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX og: <http://ogp.me/ns#>
SELECT * WHERE {
?page og:audio\u00253Atitle ?title
}

# the escape here produces '%' PERCENT SIGN (U+25)
# its unescaping must lead to a Prefixed Name og:audio%3Atitle which includes
# the percent-encoding %3A (COLON).
7 changes: 7 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-07.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT\u0020*\U00000009WHERE {
?s ?p "value"
}

# the escapes here produce whitespace -- SPACESPACE (U+20) and
# CHARACTER TABULATION (U+9) -- surrounding the `*` token in the
# SELECT projection.
6 changes: 6 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-08.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT * WHERE {
?s ?p \u0022value"
}

# the escape here produces QUOTATION MARK (U+22)
# its unescaping must lead to the literal 'value'.
5 changes: 5 additions & 0 deletions sparql/sparql12/syntax-escaping/codepoint-esc-bad-03.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s ?p "\\u0041"
}
# Legal codepoint escape of LATIN CAPITAL LETTER A (U+41), resulting in an
# invalid backslash escape \A.
68 changes: 68 additions & 0 deletions sparql/sparql12/syntax-escaping/manifest.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <https://w3c.github.io/rdf-tests/sparql/sparql12/escaping#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
@prefix dawgt: <http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#> .

:manifest rdf:type mf:Manifest ;
rdfs:label "SPARQL Codepoint-Escaping Tests" ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should indicate that these are related to the character stream processing. Calling them "escaping" is too general.

Suggestion:

  1. Rename syntax-escaping/ as syntax-char-stream-processing/
  2. rdfs:label "Character Stream Processing Tests" ;

Copy link
Contributor Author

@kasei kasei Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@afs I can rename as requested, but unsure about the exact naming (and rdfs:label) here. "Codepoint Escape" is a term used in the spec, but I don't think we use anything similar to "Character Stream Processing". I'm obviously biased as the author here, but I think without context I'd be confused by what "Character Stream Processing Tests" were, but would have a pretty good idea about "Codepoint-Escaping Tests". Thoughts?

mf:entries
(
:codepoint-esc-01
:codepoint-esc-02
:codepoint-esc-bad-03
:codepoint-esc-04
:codepoint-esc-05
:codepoint-esc-06
:codepoint-esc-07
:codepoint-esc-08
) .


:codepoint-esc-01 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-01.rq" ;
mf:action <codepoint-esc-01.rq> .

:codepoint-esc-02 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-02.rq" ;
rdfs:comment "codepoint escape for the backslash of a PN_LOCAL_ESC in the PN_LOCAL part of a PrefixedName" ;
mf:action <codepoint-esc-02.rq> .

:codepoint-esc-bad-03 rdf:type mf:NegativeSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-bad-03.rq" ;
rdfs:comment "codepoint escape that results in an invalid backslash escape (requires handling codepoint escaping before backslash escaping)" ;
mf:action <codepoint-esc-bad-03.rq> .

:codepoint-esc-04 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-04.rq" ;
rdfs:comment "codepoint escape that results in a valid backslash escape" ;
mf:action <codepoint-esc-04.rq> .

:codepoint-esc-05 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-05.rq" ;
mf:action <codepoint-esc-05.rq> .

:codepoint-esc-06 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-06.rq" ;
rdfs:comment "codepoint escape for the percent sign in the PL_LOCAL part of a PrefixedName" ;
mf:action <codepoint-esc-06.rq> .

:codepoint-esc-07 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-07.rq" ;
rdfs:comment "codepoint escape for whitespace separating the projection tokens: SELECT * WHERE" ;
mf:action <codepoint-esc-07.rq> .

:codepoint-esc-08 rdf:type mf:PositiveSyntaxTest ;
dawgt:approval dawgt:Proposed ;
mf:name "codepoint-esc-08.rq" ;
rdfs:comment "codepoint escape for the starting double-quote of a literal" ;
mf:action <codepoint-esc-08.rq> .