Allow escaped characters in SIP URI user part and authentication username
This commit is contained in:
@@ -206,13 +206,10 @@ class Account(val accp: String) {
|
|||||||
fun checkAuthUser(au: String): Boolean {
|
fun checkAuthUser(au: String): Boolean {
|
||||||
if (au == "") return true
|
if (au == "") return true
|
||||||
val ud = au.split("@")
|
val ud = au.split("@")
|
||||||
val userIDRegex = Regex("^([* .!%_`'~]|[+]|[-a-zA-Z0-9]){1,64}\$")
|
return when (ud.size) {
|
||||||
val telnoRegex = Regex("^[+]?[0-9]{1,16}\$")
|
1 -> Utils.checkUriUser(au)
|
||||||
if (ud.size == 1) {
|
2 -> Utils.checkUriUser(ud[0]) && Utils.checkDomain(ud[1])
|
||||||
return userIDRegex.matches(ud[0]) || telnoRegex.matches(ud[0])
|
else -> false
|
||||||
} else {
|
|
||||||
return (userIDRegex.matches(ud[0]) || telnoRegex.matches(ud[0])) &&
|
|
||||||
Utils.checkDomain(ud[1])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,8 +161,10 @@ object Utils {
|
|||||||
checkIpV6(bracketedIp.substring(1, bracketedIp.length - 2))
|
checkIpV6(bracketedIp.substring(1, bracketedIp.length - 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUriUser(user: String): Boolean {
|
fun checkUriUser(user: String): Boolean {
|
||||||
user.forEach { if (!(it.isLetterOrDigit() || "-_.!~*\'()&=+\$,;?/".contains(it))) return false }
|
val escaped = """%(\d|A|B|C|D|E|F|a|b|c|d|e|f){2}""".toRegex()
|
||||||
|
escaped.replace(user, "").forEach {
|
||||||
|
if (!(it.isLetterOrDigit() || "-_.!~*\'()&=+\$,;?/".contains(it))) return false }
|
||||||
return user.isNotEmpty() && !checkIpV4(user) && !checkIpV6(user)
|
return user.isNotEmpty() && !checkIpV4(user) && !checkIpV6(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user