diff --git a/mobile/src/main/scala/com/github/shadowsocks/database/Profile.scala b/mobile/src/main/scala/com/github/shadowsocks/database/Profile.scala index 9fb9782d..53581e85 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/database/Profile.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/database/Profile.scala @@ -96,12 +96,12 @@ class Profile { def toUri: Uri = { val builder = new Uri.Builder() .scheme("ss") - .authority("%s@%s:%d".formatLocal(Locale.ENGLISH, + .encodedAuthority("%s@%s:%d".formatLocal(Locale.ENGLISH, Base64.encodeToString("%s:%s".formatLocal(Locale.ENGLISH, method, password).getBytes, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE), host, remotePort)) val configuration = new PluginConfiguration(plugin) if (configuration.selected.nonEmpty) - builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString) + builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString(false)) if (!nameIsEmpty) builder.fragment(name) builder.build() } diff --git a/mobile/src/main/scala/com/github/shadowsocks/utils/Parser.scala b/mobile/src/main/scala/com/github/shadowsocks/utils/Parser.scala index a58efc49..a571bad6 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/utils/Parser.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/utils/Parser.scala @@ -21,7 +21,7 @@ package com.github.shadowsocks.utils import android.net.Uri -import android.util.Log +import android.util.{Base64, Log} import com.github.shadowsocks.database.Profile object Parser { @@ -48,18 +48,21 @@ object Parser { Log.e(TAG, "Unrecognized URI: " + m.matched) null } - case userInfoPattern(method, password) => - val profile = new Profile - profile.method = method - profile.password = password - profile.host = uri.getHost - profile.remotePort = uri.getPort - profile.plugin = uri.getQueryParameter(Key.plugin) - profile.name = uri.getFragment - profile - case _ => - Log.e(TAG, "Unknown user info: " + m.matched) - null + case userInfo => + new String(Base64.decode(userInfo, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE)) match { + case userInfoPattern(method, password) => + val profile = new Profile + profile.method = method + profile.password = password + profile.host = uri.getHost + profile.remotePort = uri.getPort + profile.plugin = uri.getQueryParameter(Key.plugin) + profile.name = uri.getFragment + profile + case _ => + Log.e(TAG, "Unknown user info: " + m.matched) + null + } } }).filter(_ != null) }