Commit c64e15ac authored by Mygod's avatar Mygod

Catch URISyntaxException

parent 9ff33ec1
...@@ -31,6 +31,7 @@ import com.j256.ormlite.field.DataType ...@@ -31,6 +31,7 @@ import com.j256.ormlite.field.DataType
import com.j256.ormlite.field.DatabaseField import com.j256.ormlite.field.DatabaseField
import java.io.Serializable import java.io.Serializable
import java.net.URI import java.net.URI
import java.net.URISyntaxException
import java.util.* import java.util.*
class Profile : Serializable { class Profile : Serializable {
...@@ -67,6 +68,7 @@ class Profile : Serializable { ...@@ -67,6 +68,7 @@ class Profile : Serializable {
profile.method = match.groupValues[1] profile.method = match.groupValues[1]
profile.password = match.groupValues[2] profile.password = match.groupValues[2]
// bug in Android: https://code.google.com/p/android/issues/detail?id=192855 // bug in Android: https://code.google.com/p/android/issues/detail?id=192855
try {
val javaURI = URI(it.value) val javaURI = URI(it.value)
profile.host = javaURI.host ?: "" profile.host = javaURI.host ?: ""
if (profile.host.firstOrNull() == '[' && profile.host.lastOrNull() == ']') if (profile.host.firstOrNull() == '[' && profile.host.lastOrNull() == ']')
...@@ -75,6 +77,10 @@ class Profile : Serializable { ...@@ -75,6 +77,10 @@ class Profile : Serializable {
profile.plugin = uri.getQueryParameter(Key.plugin) profile.plugin = uri.getQueryParameter(Key.plugin)
profile.name = uri.fragment ?: "" profile.name = uri.fragment ?: ""
profile profile
} catch (e: URISyntaxException) {
Log.e(TAG, "Invalid URI: ${it.value}")
null
}
} else { } else {
Log.e(TAG, "Unknown user info: ${it.value}") Log.e(TAG, "Unknown user info: ${it.value}")
null null
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment