From c092aabe0d0f66dc895a250ced84f3ce61792b9c Mon Sep 17 00:00:00 2001 From: "Guo,Feng(RIM)" Date: Wed, 11 Jul 2018 20:16:30 +0800 Subject: [PATCH 1/3] comment build error --- library/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/build.gradle b/library/build.gradle index 0dc5ef9..e620b62 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -29,7 +29,7 @@ dependencies { def siteUrl = 'https://github.com/lzyzsd/JsBridge' def gitUrl = 'https://github.com/lzyzsd/JsBridge.git' -apply plugin: 'com.github.dcendents.android-maven' +// apply plugin: 'com.github.dcendents.android-maven' group = "com.github.lzyzsd.jsbridge" task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs From 0a39a7103f8a68b9a6f651cad108daad9e75f7fd Mon Sep 17 00:00:00 2001 From: "Guo,Feng(RIM)" Date: Wed, 11 Jul 2018 20:31:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?json=20=E8=BD=AC=E4=B9=89=E7=94=A8=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=8E=9F=E7=94=9F=EF=BC=8C=E9=81=BF=E5=85=8D=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=9B=BF=E6=8D=A2=E8=BD=AC=E4=B9=89=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E4=B8=8D=E5=AE=8C=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/github/lzyzsd/jsbridge/BridgeUtil.java | 2 +- .../java/com/github/lzyzsd/jsbridge/BridgeWebView.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeUtil.java b/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeUtil.java index ae9e55c..ce8f22e 100644 --- a/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeUtil.java +++ b/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeUtil.java @@ -17,7 +17,7 @@ public class BridgeUtil { final static String SPLIT_MARK = "/"; final static String CALLBACK_ID_FORMAT = "JAVA_CB_%s"; - final static String JS_HANDLE_MESSAGE_FROM_JAVA = "javascript:WebViewJavascriptBridge._handleMessageFromNative('%s');"; + final static String JS_HANDLE_MESSAGE_FROM_JAVA = "javascript:WebViewJavascriptBridge._handleMessageFromNative(%s);"; final static String JS_FETCH_QUEUE_FROM_JAVA = "javascript:WebViewJavascriptBridge._fetchQueue();"; public final static String JAVASCRIPT_STR = "javascript:"; diff --git a/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeWebView.java b/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeWebView.java index b24db85..34cece8 100644 --- a/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeWebView.java +++ b/library/src/main/java/com/github/lzyzsd/jsbridge/BridgeWebView.java @@ -9,6 +9,8 @@ import android.util.AttributeSet; import android.webkit.WebView; +import org.json.JSONObject; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -141,9 +143,8 @@ private void queueMessage(Message m) { void dispatchMessage(Message m) { String messageJson = m.toJson(); //escape special characters for json string 为json字符串转义特殊字符 - messageJson = messageJson.replaceAll("(\\\\)([^utrn])", "\\\\\\\\$1$2"); - messageJson = messageJson.replaceAll("(?<=[^\\\\])(\")", "\\\\\""); - messageJson = messageJson.replaceAll("(?<=[^\\\\])(\')", "\\\\\'"); + // 系统原生 API 做 Json转义,没必要自己正则替换,而且替换不一定完整 + messageJson = JSONObject.quote(messageJson); String javascriptCommand = String.format(BridgeUtil.JS_HANDLE_MESSAGE_FROM_JAVA, messageJson); // 必须要找主线程才会将数据传递出去 --- 划重点 if (Thread.currentThread() == Looper.getMainLooper().getThread()) { From 829cc14aef6f3bf31e848aeef886a8e3cc12932d Mon Sep 17 00:00:00 2001 From: guofeng <917043886@qq.com> Date: Tue, 25 Feb 2020 19:56:06 +0800 Subject: [PATCH 3/3] Create android.yml --- .github/workflows/android.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..2884129 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,17 @@ +name: Android CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew build