Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2508)

Unified Diff: Source/modules/websockets/WebSocket.cpp

Issue 222153002: Disallow connecting an insecure WebSocket from a secure page. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update expectation Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/websockets/WebSocket.cpp
diff --git a/Source/modules/websockets/WebSocket.cpp b/Source/modules/websockets/WebSocket.cpp
index 44e1300d8be7720ddca55493e7edd5c0731d1f5b..181bef490a520928be66f193529f36027dcbbc88 100644
--- a/Source/modules/websockets/WebSocket.cpp
+++ b/Source/modules/websockets/WebSocket.cpp
@@ -300,11 +300,7 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
exceptionState.throwDOMException(SyntaxError, "The URL's scheme must be either 'ws' or 'wss'. '" + m_url.protocol() + "' is not allowed.");
return;
}
- if (MixedContentChecker::isMixedContent(executionContext()->securityOrigin(), m_url)) {
- // FIXME: Throw an exception and close the connection.
- String message = "Connecting to a non-secure WebSocket server from a secure origin is deprecated.";
- executionContext()->addConsoleMessage(JSMessageSource, WarningMessageLevel, message);
- }
+
if (m_url.hasFragmentIdentifier()) {
m_state = CLOSED;
exceptionState.throwDOMException(SyntaxError, "The URL contains a fragment identifier ('" + m_url.fragmentIdentifier() + "'). Fragment identifiers are not allowed in WebSocket URLs.");
@@ -360,7 +356,12 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
if (!protocols.isEmpty())
protocolString = joinStrings(protocols, subProtocolSeperator());
- m_channel->connect(m_url, protocolString);
+ if (!m_channel->connect(m_url, protocolString)) {
+ m_state = CLOSED;
+ exceptionState.throwSecurityError("An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.");
+ releaseChannel();
+ return;
+ }
}
void WebSocket::handleSendResult(WebSocketChannel::SendResult result, ExceptionState& exceptionState)

Powered by Google App Engine
This is Rietveld 408576698