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

@ -783,6 +783,7 @@
**/
function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null) {
static $url = array();
if($GLOBALS['_use_ssl'] == "always") $ssl_mode = ENFORCE_SSL;
if($domain) $domain_key = md5($domain);
else $domain_key = 'default';

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>

View file

@ -53,6 +53,7 @@
var ssl_actions = new Array(<!--@if(count($ssl_actions))-->"{implode('","',$ssl_actions)}"<!--@end-->);
<!--@if($GLOBALS["_http_port"])-->var http_port = {$GLOBALS["_http_port"]};<!--@end-->
<!--@if($GLOBALS["_https_port"])-->var https_port = {$GLOBALS["_https_port"]};<!--@end-->
<!--@if($GLOBALS["_use_ssl"] == "always")-->var enforce_ssl = true;<!--@end-->
//]]></script>
{Context::getHtmlHeader()}