Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the bridge URLs so that they can be used in a CSP #264

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Change the bridge URLs so that they can be used in a CSP #264

wants to merge 3 commits into from

Conversation

nilswx
Copy link

@nilswx nilswx commented Jan 19, 2017

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.

This pull request fixes issue #263.

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.
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.
@nilswx nilswx changed the title Change the bridge URLs so that they can be used in a CSP (#263) Change the bridge URLs so that they can be used in a CSP Jan 19, 2017
@@ -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';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still an underscore in there. Are you sure this works as expected?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a type error. It should be wvjb-bridge-loaded, is that right? @nilswiersema

@marcuswestin
Copy link
Owner

Man, this is tricky.

On the one hand, this is clearly an improvement.

On the other hand, it's significant to ask everyone to fix up their code after an upgrade.

Is there any way to be automatically backwards compatible?

Copy link

@itbdw itbdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type error

@@ -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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a type error. It should be wvjb-bridge-loaded

@nilswiersema

@huzhenjie
Copy link

I do agree with @nilswiersema . Here is my test sample.

Problem sample

<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Security-Policy" content="default-src 'self' wss: ws: data: blob: https://__wvjb_queue_message__ 'unsafe-eval' 'unsafe-inline'; connect-src self ws: wss: *; media-src self *;">
</head>
<body>

</body>
<iframe src="https://__wvjb_queue_message__" yy_f2e_report="true" style="display: none;"></iframe>
</html>

Then it will lead to fail

The source list for Content Security Policy directive 'default-src' contains an invalid source: 'https://__wvjb_queue_message__'. It will be ignored.
Refused to frame 'https://__wvjb_queue_message__/' because it violates the following Content Security Policy directive: "default-src 'self' wss: ws: data: blob:". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.

Success sample

<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Security-Policy" content="default-src 'self' wss: ws: data: blob: https://wvjb-queue-message 'unsafe-eval' 'unsafe-inline'; connect-src self ws: wss: *; media-src self *;">
</head>
<body>

</body>
<iframe src="https://wvjb-queue-message" yy_f2e_report="true" style="display: none;"></iframe>
</html>

the difference is replace __wvjb_queue_message__ with wvjb-queue-message

@yangxyo
Copy link

yangxyo commented Aug 2, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants