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

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: Rebase Created 6 years, 8 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
« no previous file with comments | « Source/modules/websockets/NewWebSocketChannelImpl.cpp ('k') | Source/modules/websockets/WebSocketChannel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/websockets/WebSocket.cpp
diff --git a/Source/modules/websockets/WebSocket.cpp b/Source/modules/websockets/WebSocket.cpp
index 1d3cbfd39b479da182ae1c6ad5a82302917feef4..59a360c281c98b40e1181e0d09ef422b3dbaf0d3 100644
--- a/Source/modules/websockets/WebSocket.cpp
+++ b/Source/modules/websockets/WebSocket.cpp
@@ -301,11 +301,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.");
@@ -354,7 +350,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, WebSocketSendType dataType)
« no previous file with comments | « Source/modules/websockets/NewWebSocketChannelImpl.cpp ('k') | Source/modules/websockets/WebSocketChannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698