summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/uri-test.h2
-rw-r--r--src/uri.cpp22
-rw-r--r--src/uri.h2
3 files changed, 25 insertions, 1 deletions
diff --git a/src/uri-test.h b/src/uri-test.h
index 2a4cdab46..9cb4ad639 100644
--- a/src/uri-test.h
+++ b/src/uri-test.h
@@ -47,7 +47,7 @@ public:
{ "foo", "foo" },
{ "#foo", "#foo" },
{ "blah.svg#h", "blah.svg#h" },
- //{ "data:data", "data:data" },
+ { "data:data", "data:data" },
};
for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) {
diff --git a/src/uri.cpp b/src/uri.cpp
index 89f6f33e4..219bc1c96 100644
--- a/src/uri.cpp
+++ b/src/uri.cpp
@@ -26,6 +26,15 @@ URI::URI(gchar const *preformed) throw(BadURIException) {
if (!preformed) {
throw MalformedURIException();
}
+ // One day Inkscape::URI should use std::string by default
+ std::string path = std::string(preformed);
+ // Check for a data URI and parse seperately because
+ // libxml can't handle this; although svgs need to.
+ if( path.compare(0, 5, "data:") == 0 ) {
+ parseDataUri( path );
+ // Empty the uri for libxml
+ preformed = "";
+ }
uri = xmlParseURI(preformed);
if (!uri) {
throw MalformedURIException();
@@ -135,6 +144,17 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException)
filename = tmp.toNativeFilename();
return filename;
}
+
+/*
+ * Parse data:... uris so we can access their data transparently.
+ * otherwise data: is considered a malformed protocol like http:
+ * and two // as appended and the data is stored in the path of the uri.
+ */
+bool URI::parseDataUri(const std::string &uri) {
+
+ return true;
+}
+
/*
* Returns the absolute path to an existing file referenced in this URI,
* if the uri is data, the path is empty or the file doesn't exist, then
@@ -149,6 +169,8 @@ const std::string URI::getFullPath(std::string const base) const {
if(!base.empty() && !path.empty() && path[0] != '/') {
path = Glib::build_filename(base, path);
}
+ // Path normalisation should go here TODO
+
// Check the existance of the file
if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS)
|| g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) {
diff --git a/src/uri.h b/src/uri.h
index 74820cb29..a1450c27b 100644
--- a/src/uri.h
+++ b/src/uri.h
@@ -121,6 +121,8 @@ public:
URI &operator=(URI const &uri);
private:
+ bool parseDataUri(const std::string &uri);
+
class Impl {
public:
static Impl *create(xmlURIPtr uri);