add IllegalArgument checks, because parsing UUID can throw
This commit is contained in:
parent
ad3862f14a
commit
a9838339d6
|
@ -37,8 +37,13 @@ object AuthBridgeCommand : IBridgeCommand() {
|
|||
var targetUserName = target
|
||||
|
||||
val targetUUid: String = instance.nameToUUID(target)?.toString() ?: run {
|
||||
targetUserName = instance.uuidToName(UUID.fromString(target)) ?: run {
|
||||
env.respond("cannot find player by username/uuid $target")
|
||||
try {
|
||||
targetUserName = instance.uuidToName(UUID.fromString(target)) ?: run {
|
||||
env.respond("cannot find player by username/uuid $target")
|
||||
return true
|
||||
}
|
||||
} catch (e: IllegalArgumentException) {
|
||||
env.respond("invalid username/uuid $target")
|
||||
return true
|
||||
}
|
||||
target
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.google.common.cache.Cache
|
|||
import com.google.common.cache.CacheBuilder
|
||||
import matterlink.getList
|
||||
import matterlink.logger
|
||||
import matterlink.stackTraceString
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.util.*
|
||||
|
@ -121,6 +122,14 @@ object IdentitiesConfig {
|
|||
logger.info("platform: $_platform userids: $userids")
|
||||
platform.equals(_platform, true) && userids.contains(userid)
|
||||
}
|
||||
}?.key?.let { UUID.fromString(it) }
|
||||
}?.key?.let {
|
||||
try {
|
||||
UUID.fromString(it)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
logger.error("cannot parse UUID: $it")
|
||||
logger.error(e.stackTraceString)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue