This commit is contained in:
世界 2020-04-01 15:17:02 +08:00
parent f3f6a6a3e6
commit 0c24f4a240
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
2 changed files with 20 additions and 4 deletions

View File

@ -46,6 +46,16 @@ object Utils {
}
}
fun decodeUrlSafe(text: String): String {
val flags = Base64.NO_PADDING or Base64.URL_SAFE or Base64.NO_WRAP
try {
return Base64.decode(text, flags).toString(charset("UTF-8"))
} catch (e: Exception) {
e.printStackTrace()
return ""
}
}
/**
* base64 encode
*/

View File

@ -134,19 +134,25 @@ class ShadowsocksRLoader {
runCatching {
bean.obfs_param = Utils.decode(httpUrl.queryParameter("obfsparam")!!)
bean.obfs_param = Utils.decodeUrlSafe(httpUrl.queryParameter("obfsparam")!!)
}
runCatching {
bean.protocol_param = Utils.decode(httpUrl.queryParameter("protoparam")!!)
bean.protocol_param = Utils.decodeUrlSafe(httpUrl.queryParameter("protoparam")!!)
}
runCatching {
bean.remarks = Utils.decode(httpUrl.queryParameter("remarks")!!)
val remarks = httpUrl.queryParameter("remarks")
if (remarks?.isNotBlank() == true) {
bean.remarks = Utils.decodeUrlSafe(remarks)
}
}
@ -163,7 +169,7 @@ class ShadowsocksRLoader {
Base64.encodeToString("%s".format(Locale.ENGLISH, password).toByteArray(), flags),
Base64.encodeToString("%s".format(Locale.ENGLISH, obfs_param).toByteArray(), flags),
Base64.encodeToString("%s".format(Locale.ENGLISH, protocol_param).toByteArray(), flags),
Base64.encodeToString("%s".format(Locale.ENGLISH, remarks ?: "Exported From NekoX").toByteArray(), flags)).toByteArray(), flags)
Base64.encodeToString("%s".format(Locale.ENGLISH, remarks ?: "").toByteArray(), flags)).toByteArray(), flags)
}
}