add: app property for overriding the scheme used in hrefs
e.g. hrefScheme = https generally renders urls starting with https://
This commit is contained in:
parent
9748633b78
commit
dd49a26a57
4 changed files with 19 additions and 11 deletions
|
@ -1467,3 +1467,7 @@ function getLinkCount(item) {
|
||||||
}
|
}
|
||||||
return (content.match(/https?:\/\//g) || []).length;
|
return (content.match(/https?:\/\//g) || []).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getHrefScheme() {
|
||||||
|
return getProperty('hrefScheme', 'http') + '://';
|
||||||
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ HopObject.prototype.onRequest = function() {
|
||||||
// Checking if we are on the correct host to prevent at least some XSS issues
|
// Checking if we are on the correct host to prevent at least some XSS issues
|
||||||
if (req.action !== 'notfound' && req.action !== 'error' &&
|
if (req.action !== 'notfound' && req.action !== 'error' &&
|
||||||
this.href().contains('://') &&
|
this.href().contains('://') &&
|
||||||
!this.href().toLowerCase().startsWith(req.servletRequest.scheme +
|
!this.href().toLowerCase().startsWith(getHrefScheme() +
|
||||||
'://' + req.servletRequest.serverName.toLowerCase())) {
|
req.servletRequest.serverName.toLowerCase())) {
|
||||||
res.redirect(this.href(req.action === 'main' ? String.EMPTY : req.action));
|
res.redirect(this.href(req.action === 'main' ? String.EMPTY : req.action));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1049,15 +1049,18 @@ Site.prototype.getDiskSpace = function(quota) {
|
||||||
* @param {String} href
|
* @param {String} href
|
||||||
*/
|
*/
|
||||||
Site.prototype.processHref = function(href) {
|
Site.prototype.processHref = function(href) {
|
||||||
var parts, domain,
|
var parts;
|
||||||
scheme = (req.servletRequest ? req.servletRequest.scheme : 'http') + '://';
|
var scheme = getHrefScheme();
|
||||||
if (domain = getProperty('domain.' + this.name)) {
|
var domain = getProperty('domain.' + this.name);
|
||||||
|
if (domain) {
|
||||||
parts = [scheme, domain, href];
|
parts = [scheme, domain, href];
|
||||||
} else if (domain = getProperty('domain.*')) {
|
}
|
||||||
|
domain = getProperty('domain.*');
|
||||||
|
if (domain) {
|
||||||
parts = [scheme, this.name, '.', domain, href];
|
parts = [scheme, this.name, '.', domain, href];
|
||||||
} else {
|
} else {
|
||||||
var mountpoint = app.appsProperties.mountpoint;
|
var mountpoint = app.appsProperties.mountpoint;
|
||||||
(mountpoint === '/') && (mountpoint = ''); // Prevents double slashes
|
if (mountpoint === '/') mountpoint = ''; // Prevents double slashes
|
||||||
parts = [scheme, req.data.http_host, mountpoint, href];
|
parts = [scheme, req.data.http_host, mountpoint, href];
|
||||||
}
|
}
|
||||||
return parts.join('');
|
return parts.join('');
|
||||||
|
@ -1113,11 +1116,11 @@ Site.prototype.getStaticFile = function(tail) {
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
Site.prototype.getStaticUrl = function(href) {
|
Site.prototype.getStaticUrl = function(href) {
|
||||||
href || (href = '');
|
if (!href) href = '';
|
||||||
var scheme = (req.servletRequest ? req.servletRequest.scheme : 'http') + '://';
|
var scheme = getHrefScheme();
|
||||||
var host = getProperty('domain.' + this.name);
|
var host = getProperty('domain.' + this.name);
|
||||||
host || (host = getProperty('domain.*'));
|
if (!host) host = getProperty('domain.*');
|
||||||
host || (host = req.data.http_host);
|
if (!host) host = req.data.http_host;
|
||||||
return [scheme, host, app.appsProperties.staticMountpoint, '/sites/', this.name, '/', href].join('');
|
return [scheme, host, app.appsProperties.staticMountpoint, '/sites/', this.name, '/', href].join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ cron.nightly.minute = 0
|
||||||
baseUri = /
|
baseUri = /
|
||||||
hrefFunction = processHref
|
hrefFunction = processHref
|
||||||
#hrefRootPrototype = Site
|
#hrefRootPrototype = Site
|
||||||
|
#hrefScheme = https
|
||||||
|
|
||||||
# List of default and individual domain mappings
|
# List of default and individual domain mappings
|
||||||
#domain.* = antville.org
|
#domain.* = antville.org
|
||||||
|
|
Loading…
Add table
Reference in a new issue