[Pkg-javascript-commits] [sockjs-client] 16/350: Fix #79, avoid using XDRObject when connecting across schemes

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit d417dd07a3786044a53c6411f82cbe783f188c31
Author: Daniel St. Jules <danielst.jules at gmail.com>
Date:   Wed Feb 19 08:57:44 2014 -0500

    Fix #79, avoid using XDRObject when connecting across schemes
---
 lib/info.js  | 12 ++++++++----
 lib/utils.js |  6 ++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/info.js b/lib/info.js
index 65d950d..1597884 100644
--- a/lib/info.js
+++ b/lib/info.js
@@ -93,14 +93,18 @@ var createInfoReceiver = function(base_url) {
         // XHRLocalObject -> no_credentials=true
         return new InfoReceiver(base_url, utils.XHRLocalObject);
     case 2:
-        return new InfoReceiver(base_url, utils.XDRObject);
+        // IE 8/9 if the request target uses the same scheme
+        if (utils.isSameOriginScheme(base_url)) {
+            return new InfoReceiver(base_url, utils.XDRObject);
+        }
+        break;
     case 3:
         // Opera
         return new InfoReceiverIframe(base_url);
-    default:
-        // IE 7
-        return new InfoReceiverFake();
     };
+
+    // IE 7, and IE 8/9 if requesting across schemes (e.g. http -> https)
+    return new InfoReceiverFake();
 };
 
 
diff --git a/lib/utils.js b/lib/utils.js
index 80b5a77..7efed84 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -40,6 +40,12 @@ utils.isSameOriginUrl = function(url_a, url_b) {
             url_b.split('/').slice(0,3).join('/'));
 };
 
+utils.isSameOriginScheme = function(url_a, url_b) {
+    if (!url_b) url_b = _window.location.href;
+
+    return (url_a.split(':')[0] === url_b.split(':')[0]);
+};
+
 utils.getParentDomain = function(url) {
     // ipv4 ip address
     if (/^[0-9.]*$/.test(url)) return url;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list