Skip to content

Commit

Permalink
add feature for file: URL support
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
pchampin committed Oct 25, 2023
1 parent c9c13d6 commit ec13628
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion jsonld/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions jsonld/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 3 additions & 1 deletion resource/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []


Expand Down
2 changes: 2 additions & 0 deletions sophia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit ec13628

Please sign in to comment.