From ec13628d106a34464a66c85d5c3c99be331d6d88 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Wed, 25 Oct 2023 13:35:12 +0200 Subject: [PATCH] add feature for file: URL support there are a number of situations where file: URL support is not desirable: * server side code, where file: URL could be an attack vector * WASM code, where file access is not available (and won't even compile) --- jsonld/Cargo.toml | 4 +++- jsonld/src/loader.rs | 2 ++ resource/Cargo.toml | 4 +++- sophia/Cargo.toml | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jsonld/Cargo.toml b/jsonld/Cargo.toml index b4c1fb05..d804dc8c 100644 --- a/jsonld/Cargo.toml +++ b/jsonld/Cargo.toml @@ -14,7 +14,9 @@ keywords.workspace = true [features] default = [] -# This feature enables the JSON-LD parser and serializer +# This feature enables retrieval of context via file: URLs +file_url = [] +# This feature enables retrieval of context over HTTP(S) http_client = ["json-ld/reqwest"] [dependencies] diff --git a/jsonld/src/loader.rs b/jsonld/src/loader.rs index 0a9df1a6..0efc2bf0 100644 --- a/jsonld/src/loader.rs +++ b/jsonld/src/loader.rs @@ -25,7 +25,9 @@ pub type FsLoader = mod static_loader; pub use static_loader::*; +#[cfg(feature = "file_url")] mod file_url_loader; +#[cfg(feature = "file_url")] pub use file_url_loader::*; #[cfg(feature = "http_client")] diff --git a/resource/Cargo.toml b/resource/Cargo.toml index d9b7c64b..a4796373 100644 --- a/resource/Cargo.toml +++ b/resource/Cargo.toml @@ -17,7 +17,9 @@ keywords.workspace = true jsonld = ["sophia_jsonld", "futures-util"] # This feature enables the RDF/XML parser and serializer xml = ["sophia_xml"] -# This feature enables the HTTP client in dependencies +# NOT IMPLEMENTED YET: This feature enables retrieval of resource graphs over file: URLs +file_url = [] +# NOT IMPLEMENTED YET: This feature enables retrieval of resource graphs over HTTP(S) http_client = [] diff --git a/sophia/Cargo.toml b/sophia/Cargo.toml index 9b090ff6..70fae75f 100644 --- a/sophia/Cargo.toml +++ b/sophia/Cargo.toml @@ -21,6 +21,8 @@ jsonld = ["sophia_jsonld", "sophia_resource/jsonld"] xml = ["sophia_xml", "sophia_resource/xml"] # This feature enables to use the graph and dataset test macros in other crates test_macro = ["sophia_api/test_macro"] +# This feature enables the file: URL support in dependencies +file_url = ["sophia_jsonld/file_url", "sophia_resource/file_url"] # This feature enables the HTTP client in dependencies http_client = ["sophia_jsonld/http_client", "sophia_resource/http_client"]