ログインダイアログでIDNドメインを指定できる
This commit is contained in:
parent
587b505ae2
commit
767f0620a6
|
@ -45,7 +45,11 @@ class Host private constructor(
|
||||||
val cached = hostSet[srcArg]
|
val cached = hostSet[srcArg]
|
||||||
if (cached != null) return cached
|
if (cached != null) return cached
|
||||||
val src = srcArg.removeUrlSchema()
|
val src = srcArg.removeUrlSchema()
|
||||||
val ascii = IDN.toASCII(src, IDN.ALLOW_UNASSIGNED).lowercase()
|
val ascii = if( """[^A-Za-z0-9._-]""".toRegex().find(src)!=null){
|
||||||
|
IDN.toASCII(src, IDN.ALLOW_UNASSIGNED).lowercase()
|
||||||
|
}else{
|
||||||
|
IDN.toASCII(src, IDN.ALLOW_UNASSIGNED).lowercase()
|
||||||
|
}
|
||||||
val pretty = IDN.toUnicode(src, IDN.ALLOW_UNASSIGNED)
|
val pretty = IDN.toUnicode(src, IDN.ALLOW_UNASSIGNED)
|
||||||
val host = if (ascii == pretty) Host(ascii) else Host(ascii, pretty)
|
val host = if (ascii == pretty) Host(ascii) else Host(ascii, pretty)
|
||||||
hostSet[src] = host
|
hostSet[src] = host
|
||||||
|
|
|
@ -40,7 +40,7 @@ class LoginForm(
|
||||||
private val log = LogCategory("LoginForm")
|
private val log = LogCategory("LoginForm")
|
||||||
|
|
||||||
@Suppress("RegExpSimplifiable")
|
@Suppress("RegExpSimplifiable")
|
||||||
val reBadLetter = """[^A-Za-z0-9:;._-]+""".toRegex()
|
val reBadChars = """([^\p{L}\p{N}A-Za-z0-9:;._-]+)""".toRegex()
|
||||||
|
|
||||||
fun AppCompatActivity.showLoginForm(
|
fun AppCompatActivity.showLoginForm(
|
||||||
onClickOk: (
|
onClickOk: (
|
||||||
|
@ -192,8 +192,7 @@ class LoginForm(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
reBadChars.findAll(s).joinToString("") { it.value }.notEmpty()?.let {
|
||||||
reBadLetter.findAll(s).joinToString("") { it.value }.notEmpty()?.let {
|
|
||||||
showError(activity.getString(R.string.server_host_name_cant_contains_it, it))
|
showError(activity.getString(R.string.server_host_name_cant_contains_it, it))
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue