Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

fix: strip ? from entity names to prevent SPARQL variable injection (closes #6)

FABIOTESSdfe959f74a49
diff --git a/src/mapping.rs b/src/mapping.rs
index e6c8d30c..0b3e023d 100644
--- a/src/mapping.rs
+++ b/src/mapping.rs
@@ -113,7 +113,7 @@ impl MappingConfig {
fn sanitize_iri(s: &str) -> String {
s.chars()
.map(|c| match c {
- ' ' | '<' | '>' | '{' | '}' | '|' | '\\' | '^' | '`' => '_',
+ ' ' | '<' | '>' | '{' | '}' | '|' | '\\' | '^' | '`' | '?' => '_',
_ => c,
})
.collect()
@@ -152,6 +152,7 @@ mod tests {
assert_eq!(sanitize_iri("hello world"), "hello_world");
assert_eq!(sanitize_iri("a<b>c"), "a_b_c");
assert_eq!(sanitize_iri("no_change"), "no_change");
+ assert_eq!(sanitize_iri("PEAK_OF_PERFECTION_?"), "PEAK_OF_PERFECTION__");
}
#[test]