Hack to unescape URI when call or dial request comes from outside

This commit is contained in:
Juha Heinanen
2023-05-31 17:10:09 +03:00
parent 3fa107153a
commit 3b3dd30875
2 changed files with 8 additions and 1 deletions

View File

@ -855,7 +855,7 @@ class MainActivity : AppCompatActivity() {
if (uri != null) {
when (uri.scheme) {
"sip" -> {
val uriStr = uri.toString()
val uriStr = Utils.uriUnescape(uri.toString())
var ua = UserAgent.ofDomain(Utils.uriHostPart(uriStr))
if (ua == null && BaresipService.uas.size > 0)
ua = BaresipService.uas[0]

View File

@ -177,6 +177,13 @@ object Utils {
return if (checkUriUser(uri)) "$res@${aorDomain(aor)}" else res
}
private fun String.replace(vararg pairs: Pair<String, String>): String =
pairs.fold(this) { acc, (old, new) -> acc.replace(old, new, ignoreCase = true) }
fun uriUnescape(uri: String): String {
return uri.replace("%2B" to "+", "%3A" to ":", "%3B" to ";", "%40" to "@", "%3D" to "=")
}
fun aorDomain(aor: String): String {
return uriHostPart(aor)
}