Skip to content
Snippets Groups Projects
Commit a1c343af authored by echicken's avatar echicken :chicken:
Browse files

Be less stupid about handling .link pseudopages and redirecting.

parent 1a470cc4
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -93,6 +93,17 @@ function getCtrlLine(file) {
}
function getExternalLink(fn) {
const p = getPagePath(fn);
if (p === null) throw new Error('Invalid page ' + fn + ',,,' + settings.web_mods_pages);
const f = new File(p);
f.open('r');
const c = f.read().split(',');
f.close();
if (c.length < 2) throw new Error('Invalid page ' + fn + ',,,' + settings.web_mods_pages);
return c[0];
}
function _getPageList(dir) {
if (!file_isdir(dir)) return [];
......@@ -133,7 +144,7 @@ function _getPageList(dir) {
file: fn,
name: pageName(c),
title: l[1],
page: l[0],
page: fn,
type: 'link'
});
} else {
......
......@@ -6,9 +6,10 @@
load(settings.web_lib + 'sidebar.js');
var page = typeof http_request.query.page == 'undefined' ? '000-home.xjs' : http_request.query.page[0];
if (page.search(/(?:https?|ftp|telnet|ssh|gopher|rlogin|news):\/\/[^\s'"'<>()]*|[-\w.+]+@(?:[-\w]+\.)+[\w]{2,6}/i) > -1) {
if (page.search(/\.link$/) > -1) {
var loc = getExternalLink(page);
http_reply.status = '301 Moved Permanently';
http_reply.header['Location'] = page;
http_reply.header['Location'] = loc;
exit();
}
var pagePath = getPagePath(page);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment