Commit be503618 authored by Mygod's avatar Mygod Committed by Max Lv

Fix issues about SIP002

parent 212c3f66
...@@ -96,12 +96,12 @@ class Profile { ...@@ -96,12 +96,12 @@ class Profile {
def toUri: Uri = { def toUri: Uri = {
val builder = new Uri.Builder() val builder = new Uri.Builder()
.scheme("ss") .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.encodeToString("%s:%s".formatLocal(Locale.ENGLISH, method, password).getBytes,
Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE), host, remotePort)) Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE), host, remotePort))
val configuration = new PluginConfiguration(plugin) val configuration = new PluginConfiguration(plugin)
if (configuration.selected.nonEmpty) if (configuration.selected.nonEmpty)
builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString) builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString(false))
if (!nameIsEmpty) builder.fragment(name) if (!nameIsEmpty) builder.fragment(name)
builder.build() builder.build()
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
package com.github.shadowsocks.utils package com.github.shadowsocks.utils
import android.net.Uri import android.net.Uri
import android.util.Log import android.util.{Base64, Log}
import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.Profile
object Parser { object Parser {
...@@ -48,6 +48,8 @@ object Parser { ...@@ -48,6 +48,8 @@ object Parser {
Log.e(TAG, "Unrecognized URI: " + m.matched) Log.e(TAG, "Unrecognized URI: " + m.matched)
null null
} }
case userInfo =>
new String(Base64.decode(userInfo, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE)) match {
case userInfoPattern(method, password) => case userInfoPattern(method, password) =>
val profile = new Profile val profile = new Profile
profile.method = method profile.method = method
...@@ -61,5 +63,6 @@ object Parser { ...@@ -61,5 +63,6 @@ object Parser {
Log.e(TAG, "Unknown user info: " + m.matched) Log.e(TAG, "Unknown user info: " + m.matched)
null null
} }
}
}).filter(_ != null) }).filter(_ != 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