From da4e90835b93d1d63a4c742a9027a70ca0021503 Mon Sep 17 00:00:00 2001 From: lcn Date: Fri, 5 Feb 2021 11:44:04 +0800 Subject: [PATCH] =?UTF-8?q?BridgeHelper.shouldOverrideUrlLoading(String=20?= =?UTF-8?q?url)=20=E6=96=B9=E6=B3=95=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BC=A0?= =?UTF-8?q?=E4=BA=BA=E7=9A=84=20url=20=E4=B8=AD=E5=8C=85=E5=90=AB=E6=9C=AA?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=9A=84=E7=AC=A6=E5=8F=B7=E2=80=9C%?= =?UTF-8?q?=E2=80=9D=E5=92=8C=E2=80=9C+=E2=80=9D=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20URLDecoder.decode=20=E6=8A=9B=E5=87=BA=20I?= =?UTF-8?q?llegalArgumentException=EF=BC=8C=E5=9C=A8=20decode=20=E5=89=8D?= =?UTF-8?q?=E5=B0=86=E8=AF=A5=E7=89=B9=E6=AE=8A=E7=AC=A6=E5=8F=B7=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E7=BC=96=E7=A0=81=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/github/lzyzsd/jsbridge/BridgeHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeHelper.java b/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeHelper.java index 18b18fc5..d4e4bfe9 100644 --- a/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeHelper.java +++ b/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeHelper.java @@ -269,7 +269,9 @@ private void webViewLoadLocalJs() { public boolean shouldOverrideUrlLoading(String url) { try { - url = URLDecoder.decode(url, "UTF-8"); + // decode 之前,处理 % 和 + + String replacedUrl = url.replaceAll("%(?![0-9a-fA-F]{2})", "%25").replaceAll("\\+", "%2B"); + url = URLDecoder.decode(replacedUrl, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.w(TAG, e); }