summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-09-04 11:30:15 +0200
committerCarlos Garnacho <carlosg@gnome.org>2022-09-04 11:30:15 +0200
commitcc13adfb270553866b8c7dcd8b80c8cfa863b800 (patch)
tree6265b666ee3ef7d4e546250ab6dbb9e65f3cb301 /tests
parent6dc36b382abb5ddb00056e823d18b01a81e6d673 (diff)
downloadtracker-cc13adfb270553866b8c7dcd8b80c8cfa863b800.tar.gz
libtracker-sparql: Fix off by one in checks for escaped IRIs
The 0x20 character should also be escaped as per the SPARQL reference, and it correctly is when setting a TrackerResource IRI. Even though, the fast path check for the presence of characters that should be escaped is missing it, so it would be possible to let IRIs that only have this invalid character as valid. Since 0x20 (whitespace) is possibly the most ubiquitous character that should be escaped, it's a bit of an oversight. Fixes: 33031007c ("libtracker-sparql: Escape illegal characters in IRIREF...")
Diffstat (limited to 'tests')
-rw-r--r--tests/libtracker-sparql/tracker-resource-test.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/libtracker-sparql/tracker-resource-test.c b/tests/libtracker-sparql/tracker-resource-test.c
index aa78ea552..c08cd150a 100644
--- a/tests/libtracker-sparql/tracker-resource-test.c
+++ b/tests/libtracker-sparql/tracker-resource-test.c
@@ -231,6 +231,12 @@ test_resource_iri_valid_chars (void)
g_assert_cmpstr (tracker_resource_get_first_uri (resource, "rdf:type"), ==, "http://example.com/resource");
g_object_unref (resource);
+ resource = tracker_resource_new ("http://example.com/A B");
+ tracker_resource_set_uri (resource, "rdf:type", "http://example.com/A B");
+ g_assert_cmpstr (tracker_resource_get_identifier (resource), ==, "http://example.com/A%20B");
+ g_assert_cmpstr (tracker_resource_get_first_uri (resource, "rdf:type"), ==, "http://example.com/A%20B");
+ g_object_unref (resource);
+
resource = tracker_resource_new ("http://example.com/♥️");
tracker_resource_set_uri (resource, "rdf:type", "http://example.com/♥️");
g_assert_cmpstr (tracker_resource_get_identifier (resource), ==, "http://example.com/♥️");