Decode Sophos Email Appliance proxy links

This commit is contained in:
M66B 2021-09-12 13:06:49 +02:00
parent 86ae66c88a
commit c71664fcda
1 changed files with 19 additions and 0 deletions

View File

@ -41,6 +41,7 @@ import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.util.Base64;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@ -65,6 +66,8 @@ import androidx.preference.PreferenceManager;
import java.net.IDN;
import java.net.InetAddress;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -569,6 +572,22 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
p = u.indexOf("/");
}
changed = (result != null);
url = (result == null ? uri : result);
} else if (uri.getQueryParameterNames().size() == 1) {
// Sophos Email Appliance
Uri result = null;
String key = uri.getQueryParameterNames().iterator().next();
if (TextUtils.isEmpty(uri.getQueryParameter(key)))
try {
String data = new String(Base64.decode(key, Base64.DEFAULT));
int u = data.indexOf("&&url=");
if (u > 0)
result = Uri.parse(URLDecoder.decode(data.substring(u + 6), StandardCharsets.UTF_8.name()));
} catch (Throwable ex) {
Log.w(ex);
}
changed = (result != null);
url = (result == null ? uri : result);
} else