/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Functions to redact strings to remove PII before logging them
/// Redact a URL. /// /// It's tricky to redact an URL without revealing PII. We check for various known bad URL forms /// and report them, otherwise we just log "<URL>". pubfn redact_url(url: &str) -> String { if url.is_empty() { return"<URL (empty)>".to_string();
} match url.find(':') {
None => "<URL (no scheme)>".to_string(),
Some(n) => { letmut chars = url[0..n].chars(); match chars.next() { // No characters in the scheme
None => return"<URL (empty scheme)>".to_string(),
Some(c) => { // First character must be alphabetic if !c.is_ascii_alphabetic() { return"<URL (invalid scheme)>".to_string();
}
}
} for c in chars { // Subsequent characters must be in the set ( alpha | digit | "+" | "-" | "." ) if !(c.is_ascii_alphanumeric() || c == '+' || c == '-' || c == '.') { return"<URL (invalid scheme)>".to_string();
}
} "<URL>".to_string()
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.