From 1b37aac6d39d82e4e9b62a4f4b7eb6ee69f7c10f Mon Sep 17 00:00:00 2001 From: Nils Wiersema Date: Thu, 19 Jan 2017 19:49:05 +0100 Subject: [PATCH 1/2] Change the bridge URLs so that they can be used in a CSP The previous URLs contained leading/middle/trailing underscores, which are illegal to use as 'host-char' in a Content-Security-Policy. Changing them to hyphens makes WebViewJavascriptBridge compatible with solutions requiring a CSP. --- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 4 ++-- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 54d80acc..083fe0b7 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -9,8 +9,8 @@ #define kOldProtocolScheme @"wvjbscheme" #define kNewProtocolScheme @"https" -#define kQueueHasMessage @"__wvjb_queue_message__" -#define kBridgeLoaded @"__bridge_loaded__" +#define kQueueHasMessage @"wvjb-queue-message" +#define kBridgeLoaded @"wvjb-bridge-loaded" typedef void (^WVJBResponseCallback)(id responseData); typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 670a552f..535cefde 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -38,7 +38,7 @@ var messageHandlers = {}; var CUSTOM_PROTOCOL_SCHEME = 'https'; - var QUEUE_HAS_MESSAGE = '__wvjb_queue_message__'; + var QUEUE_HAS_MESSAGE = 'wvjb-queue-message'; var responseCallbacks = {}; var uniqueId = 1; From 861d4964fd05fe6eeeb2f0d422e9121e6c396859 Mon Sep 17 00:00:00 2001 From: Nils Wiersema Date: Thu, 19 Jan 2017 19:50:39 +0100 Subject: [PATCH 2/2] Update README.md to reflect the change to https://wvjb-bridge-loaded The previous URLs contained leading/middle/trailing underscores, which are illegal to use as 'host-char' in a Content-Security-Policy. Changing them to hyphens makes WebViewJavascriptBridge compatible with solutions requiring a CSP. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c38d8beb..9160693d 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ function setupWebViewJavascriptBridge(callback) { window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'https://__bridge_loaded__'; + WVJBIframe.src = 'https://wvjb-bridge_loaded'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) }