Skip to content

Commit ec13628

Browse files
committed
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)
1 parent c9c13d6 commit ec13628

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

jsonld/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ keywords.workspace = true
1414

1515
[features]
1616
default = []
17-
# This feature enables the JSON-LD parser and serializer
17+
# This feature enables retrieval of context via file: URLs
18+
file_url = []
19+
# This feature enables retrieval of context over HTTP(S)
1820
http_client = ["json-ld/reqwest"]
1921

2022
[dependencies]

jsonld/src/loader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ pub type FsLoader =
2525
mod static_loader;
2626
pub use static_loader::*;
2727

28+
#[cfg(feature = "file_url")]
2829
mod file_url_loader;
30+
#[cfg(feature = "file_url")]
2931
pub use file_url_loader::*;
3032

3133
#[cfg(feature = "http_client")]

resource/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ keywords.workspace = true
1717
jsonld = ["sophia_jsonld", "futures-util"]
1818
# This feature enables the RDF/XML parser and serializer
1919
xml = ["sophia_xml"]
20-
# This feature enables the HTTP client in dependencies
20+
# NOT IMPLEMENTED YET: This feature enables retrieval of resource graphs over file: URLs
21+
file_url = []
22+
# NOT IMPLEMENTED YET: This feature enables retrieval of resource graphs over HTTP(S)
2123
http_client = []
2224

2325

sophia/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jsonld = ["sophia_jsonld", "sophia_resource/jsonld"]
2121
xml = ["sophia_xml", "sophia_resource/xml"]
2222
# This feature enables to use the graph and dataset test macros in other crates
2323
test_macro = ["sophia_api/test_macro"]
24+
# This feature enables the file: URL support in dependencies
25+
file_url = ["sophia_jsonld/file_url", "sophia_resource/file_url"]
2426
# This feature enables the HTTP client in dependencies
2527
http_client = ["sophia_jsonld/http_client", "sophia_resource/http_client"]
2628

0 commit comments

Comments
 (0)