17100567 : Enable SSL always

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5126 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2008-12-18 08:53:18 +00:00
parent c6397a1f83
commit 602837f8c2
4 changed files with 42 additions and 13 deletions

View file

@ -328,26 +328,36 @@ String.prototype.setQuery = function(key, val) {
}
uri = uri.replace(re,toReplace);
}
if(typeof(ssl_actions)!='undefined' && typeof(ssl_actions.length)!='undefined' && uri.getQuery('act')) {
var bUseSSL = false;
if(typeof(enforce_ssl)!='undefined' && enforce_ssl)
{
bUseSSL = true;
}
else if(typeof(ssl_actions)!='undefined' && typeof(ssl_actions.length)!='undefined' && uri.getQuery('act')) {
var act = uri.getQuery('act');
for(i=0;i<ssl_actions.length;i++) {
if(ssl_actions[i]==act) {
var re = /http:\/\/([^:\/]+)(:\d+|)/i;
var check = re.exec(uri);
if(check)
{
var toReplace = "https://"+check[1];
if(typeof(https_port)!='undefined' && https_port != 443)
{
toReplace += ":" + https_port;
}
uri = uri.replace(re,toReplace);
}
bUseSSL = true;
break;
}
}
}
if(bUseSSL)
{
var re = /http:\/\/([^:\/]+)(:\d+|)/i;
var check = re.exec(uri);
if(check)
{
var toReplace = "https://"+check[1];
if(typeof(https_port)!='undefined' && https_port != 443)
{
toReplace += ":" + https_port;
}
uri = uri.replace(re,toReplace);
}
}
return encodeURI(uri);
}

View file

@ -49,6 +49,23 @@ describe('SetQuery', {
targetsp = "https://www.zeroboard.com:443/?q=r";
http_port = 80;
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://www.zeroboard.com/?q=r&act=dispLogin2");
},
'should work if enforce_ssl is set' : function() {
target = "http://www.zeroboard.com/";
enforce_ssl = true;
value_of(target.setQuery("act","dispLogin")).should_be("https://www.zeroboard.com/?act=dispLogin");
},
'should work if enforce_ssl is set with 443 port' : function() {
target = "http://www.zeroboard.com/";
enforce_ssl = true;
https_port = 443;
value_of(target.setQuery("act","dispLogin")).should_be("https://www.zeroboard.com/?act=dispLogin");
},
'should work if enforce_ssl is set with none-443 port' : function() {
target = "http://www.zeroboard.com/";
enforce_ssl = true;
https_port = 445;
value_of(target.setQuery("act","dispLogin")).should_be("https://www.zeroboard.com:445/?act=dispLogin");
}
})
// ]]></script>