1
pub mod database_operations;
2
pub mod database_privilege_operations;
3
pub mod user_operations;
4

            
5
#[inline]
6
#[must_use]
7
1
pub fn quote_literal(s: &str) -> String {
8
1
    format!("'{}'", s.replace('\'', r"\'"))
9
1
}
10

            
11
#[inline]
12
#[must_use]
13
1
pub fn quote_identifier(s: &str) -> String {
14
1
    format!("`{}`", s.replace('`', r"\`"))
15
1
}
16

            
17
#[cfg(test)]
18
mod tests {
19
    use super::*;
20
    #[test]
21
1
    fn test_quote_literal() {
22
1
        let payload = "' OR 1=1 --";
23
1
        assert_eq!(quote_literal(payload), r#"'\' OR 1=1 --'"#);
24
1
    }
25

            
26
    #[test]
27
1
    fn test_quote_identifier() {
28
1
        let payload = "` OR 1=1 --";
29
1
        assert_eq!(quote_identifier(payload), r#"`\` OR 1=1 --`"#);
30
1
    }
31
}