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
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -93,6 +93,17 @@ function getCtrlLine(file) { ...@@ -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) { function _getPageList(dir) {
if (!file_isdir(dir)) return []; if (!file_isdir(dir)) return [];
...@@ -133,7 +144,7 @@ function _getPageList(dir) { ...@@ -133,7 +144,7 @@ function _getPageList(dir) {
file: fn, file: fn,
name: pageName(c), name: pageName(c),
title: l[1], title: l[1],
page: l[0], page: fn,
type: 'link' type: 'link'
}); });
} else { } else {
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
load(settings.web_lib + 'sidebar.js'); load(settings.web_lib + 'sidebar.js');
var page = typeof http_request.query.page == 'undefined' ? '000-home.xjs' : http_request.query.page[0]; 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.status = '301 Moved Permanently';
http_reply.header['Location'] = page; http_reply.header['Location'] = loc;
exit(); exit();
} }
var pagePath = getPagePath(page); 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