aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uri.c12
-rw-r--r--tests/bad/bad-colon-in-first-path-segment.ttl3
-rw-r--r--tests/bad/manifest.ttl6
3 files changed, 20 insertions, 1 deletions
diff --git a/src/uri.c b/src/uri.c
index 7b172e42..7f849d62 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -141,7 +141,8 @@ serd_uri_parse(const uint8_t* utf8, SerdURI* out)
{
*out = SERD_URI_NULL;
- const uint8_t* ptr = utf8;
+ const uint8_t* ptr = utf8;
+ bool path_has_slash = false;
/* See http://tools.ietf.org/html/rfc3986#section-3
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
@@ -203,6 +204,15 @@ path:
switch (c) {
case '?': goto query;
case '#': goto fragment;
+ case '/':
+ ++out->path.len;
+ path_has_slash = true;
+ break;
+ case ':':
+ if (!path_has_slash) {
+ // RFC3987 S2.2: isegment-nz-nc can not contain a colon
+ return SERD_ERR_BAD_SYNTAX;
+ }
default:
++out->path.len;
}
diff --git a/tests/bad/bad-colon-in-first-path-segment.ttl b/tests/bad/bad-colon-in-first-path-segment.ttl
new file mode 100644
index 00000000..ceebdb81
--- /dev/null
+++ b/tests/bad/bad-colon-in-first-path-segment.ttl
@@ -0,0 +1,3 @@
+@prefix eg: <http://example.org/> .
+
+<_:x> <eg:x> <eg:x> .
diff --git a/tests/bad/manifest.ttl b/tests/bad/manifest.ttl
index 1e21397d..9600acee 100644
--- a/tests/bad/manifest.ttl
+++ b/tests/bad/manifest.ttl
@@ -28,6 +28,7 @@
<#bad-char-in-local>
<#bad-char-in-prefix>
<#bad-char-in-uri>
+ <#bad-colon-in-first-path-segment>
<#bad-datatype>
<#bad-dot-after-subject>
<#bad-eof-in-blank>
@@ -174,6 +175,11 @@
mf:name "bad-char-in-uri" ;
mf:action <bad-char-in-uri.ttl> .
+<#bad-colon-in-first-path-segment>
+ rdf:type rdft:TestTurtleNegativeSyntax ;
+ mf:name "bad-colon-in-first-path-segment" ;
+ mf:action <bad-colon-in-first-path-segment.ttl> .
+
<#bad-datatype>
rdf:type rdft:TestTurtleNegativeSyntax ;
mf:name "bad-datatype" ;