aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--serd/serd.h7
-rw-r--r--src/node.c4
-rw-r--r--src/serdi.c2
-rw-r--r--tests/serd_test.c15
4 files changed, 12 insertions, 16 deletions
diff --git a/serd/serd.h b/serd/serd.h
index e576398b..1f30065b 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -629,15 +629,14 @@ serd_node_resolve(const SerdNode* node, const SerdNode* base);
/**
Create a new file URI node from a file system path and optional hostname.
- Backslashes in Windows paths will be converted and '%' will always be
- percent encoded. If `escape` is true, all other invalid characters will be
- percent encoded as well.
+ Backslashes in Windows paths will be converted, and other characters will be
+ percent encoded as necessary.
If `path` is relative, `hostname` is ignored.
*/
SERD_API
SerdNode*
-serd_new_file_uri(const char* path, const char* hostname, bool escape);
+serd_new_file_uri(const char* path, const char* hostname);
/**
Create a new URI from a string, relative to a base URI.
diff --git a/src/node.c b/src/node.c
index cbad34bf..cc11fadc 100644
--- a/src/node.c
+++ b/src/node.c
@@ -455,7 +455,7 @@ is_uri_path_char(const char c)
}
SerdNode*
-serd_new_file_uri(const char* path, const char* hostname, bool escape)
+serd_new_file_uri(const char* path, const char* hostname)
{
const size_t path_len = strlen(path);
const size_t hostname_len = hostname ? strlen(hostname) : 0;
@@ -476,7 +476,7 @@ serd_new_file_uri(const char* path, const char* hostname, bool escape)
serd_buffer_sink("/", 1, 1, &buffer);
} else if (path[i] == '%') {
serd_buffer_sink("%%", 1, 2, &buffer);
- } else if (!escape || is_uri_path_char(path[i])) {
+ } else if (is_uri_path_char(path[i])) {
serd_buffer_sink(path + i, 1, 1, &buffer);
} else {
char escape_str[4] = { '%', 0, 0, 0 };
diff --git a/src/serdi.c b/src/serdi.c
index 5e64e709..14eb04c5 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -198,7 +198,7 @@ main(int argc, char** argv)
if (a < argc) { // Base URI given on command line
base = serd_new_uri(argv[a]);
} else if (!from_string && !from_stdin) { // Use input file URI
- base = serd_new_file_uri(input, NULL, true);
+ base = serd_new_file_uri(input, NULL);
}
FILE* out_fd = stdout;
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 2a8f7edf..a05606a3 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -99,7 +99,6 @@ eof_test_error(void* stream)
static void
test_file_uri(const char* hostname,
const char* path,
- bool escape,
const char* expected_uri,
const char* expected_path)
{
@@ -107,7 +106,7 @@ test_file_uri(const char* hostname,
expected_path = path;
}
- SerdNode* node = serd_new_file_uri(path, hostname, escape);
+ SerdNode* node = serd_new_file_uri(path, hostname);
const char* node_str = serd_node_string(node);
char* out_hostname = NULL;
char* out_path = serd_file_uri_parse(node_str, &out_hostname);
@@ -367,17 +366,15 @@ test_strerror(void)
static void
test_uri_parsing(void)
{
- test_file_uri(NULL, "C:/My 100%", true,
+ test_file_uri(NULL, "C:/My 100%",
"file:///C:/My%20100%%", NULL);
- test_file_uri("ahost", "C:\\Pointless Space", true,
+ test_file_uri("ahost", "C:\\Pointless Space",
"file://ahost/C:/Pointless%20Space", "C:/Pointless Space");
- test_file_uri(NULL, "/foo/bar", true,
+ test_file_uri(NULL, "/foo/bar",
"file:///foo/bar", NULL);
- test_file_uri("bhost", "/foo/bar", true,
+ test_file_uri("bhost", "/foo/bar",
"file://bhost/foo/bar", NULL);
- test_file_uri(NULL, "a/relative path", false,
- "a/relative path", NULL);
- test_file_uri(NULL, "a/relative <path>", true,
+ test_file_uri(NULL, "a/relative <path>",
"a/relative%20%3Cpath%3E", NULL);
// Test tolerance of parsing junk URI escapes