Return empty PSK if unrecognized
This commit is contained in:
@@ -31,9 +31,11 @@ class P2pSupplicantConfiguration {
|
|||||||
fun readPsk(): String? {
|
fun readPsk(): String? {
|
||||||
return try {
|
return try {
|
||||||
val match = pskParser.findAll(content ?: return null).single()
|
val match = pskParser.findAll(content ?: return null).single()
|
||||||
val result = match.groupValues[2] + match.groupValues[3] // only one will match and hold non-empty value
|
if (match.groups[2] == null && match.groups[3] == null) "" else {
|
||||||
check(result.length in 8..63)
|
val result = match.groupValues[2] + match.groupValues[3] // only one will match and hold non-empty value
|
||||||
result
|
check(result.length in 8..63)
|
||||||
|
result
|
||||||
|
}
|
||||||
} catch (e: NoSuchElementException) {
|
} catch (e: NoSuchElementException) {
|
||||||
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
|
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
|
||||||
null
|
null
|
||||||
|
|||||||
Reference in New Issue
Block a user