pike.git/
lib/
modules/
Sql.pmod/
module.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2015-10-07
2015-10-07 12:38:03 by Henrik Grubbström (Grubba) <grubba@grubba.org>
840eaa975b324c82b80cf5942447d3fac45f5a84 (
26
lines) (+
26
/-
0
)
[
Show
|
Annotate
]
Branch:
8.1
Sql: Added censor_sql_url().
37:
//! //! @seealso //! @[Val.null]
+
+
//! Redact the password (if any) from an Sql-url.
+
//!
+
//! @param sql_url
+
//! Sql-url possibly containing an unredacted password.
+
//!
+
//! @returns
+
//! Returns the same Sql-url but with the password (if any)
+
//! replaced by the string @expr{"CENSORED"@}.
+
string censor_sql_url(string sql_url)
+
{
+
array(string) a = sql_url/"://";
+
string prot = a[0];
+
string host = a[1..] * "://";
+
a = host/"@";
+
if (sizeof(a) > 1) {
+
host = a[-1];
+
a = (a[..<1] * "@")/":";
+
string user = a[0];
+
if (sizeof(a) > 1) {
+
sql_url = prot + "://" + user + ":CENSORED@" + host;
+
}
+
}
+
return sql_url;
+
}