Made IrcCodec::sanitize part of the public API and improved documentation a bit.

This commit is contained in:
Aaron Weiss 2018-05-05 13:52:51 +02:00
parent 625b59d605
commit b452921a03
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF

View file

@ -18,9 +18,9 @@ impl IrcCodec {
}
/// Sanitizes the input string by cutting up to (and including) the first occurence of a line
/// terminiating phrase (`\r\n`, `\r`, or `\n`). This is used in sending messages back to
/// prevent the injection of additional commands.
pub(crate) fn sanitize(mut data: String) -> String {
/// terminiating phrase (`\r\n`, `\r`, or `\n`). This is used in sending messages through the
/// codec to prevent the injection of additional commands.
pub fn sanitize(mut data: String) -> String {
// n.b. ordering matters here to prefer "\r\n" over "\r"
if let Some((pos, len)) = ["\r\n", "\r", "\n"]
.iter()