Release v122 with Tachyon integration and resilient Xray downloads
OpenWrt IPK and APK / Validate source and resolve stable SDKs (push) Waiting to run
OpenWrt IPK and APK / Validate source and resolve stable SDKs (push) Waiting to run
This commit is contained in:
1 parent
f4ccbf82f3
commit
70a4705e67
50 files changed
+3173
-181
No files matched your search
@@ -0,0 +1,26 @@
|
||||
const fs = require('node:fs');
|
||||
const vm = require('node:vm');
|
||||
const assert = require('node:assert/strict');
|
||||
const source = fs.readFileSync('vps/owrt-remote-hub.py', 'utf8');
|
||||
const start = source.indexOf('function renderTachyon(router) {{');
|
||||
const end = source.indexOf('\nfunction render(list)', start);
|
||||
const code = source.slice(start, end).replaceAll('{{', '{').replaceAll('}}', '}');
|
||||
const escape = value => String(value).replace(/[&<>"']/g, ch => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[ch]));
|
||||
const context = {escapeHtml: escape, escapeAttr: escape};
|
||||
vm.createContext(context); vm.runInContext(code, context);
|
||||
assert.equal(context.renderTachyon({}), '');
|
||||
assert.equal(context.renderTachyon({tachyon: {installed: false}}), '');
|
||||
const router = {permissions: {admin: true}, tachyon: {installed: true, version: '2.0.0~beta.8-1', online: true, url: '/tachyon/a/'}};
|
||||
let html = context.renderTachyon(router);
|
||||
assert(html.includes('Открыть Tachyon'));
|
||||
assert(html.includes('target="_blank"'));
|
||||
assert(html.includes('Online'));
|
||||
assert(html.includes('href="/tachyon/a/"'));
|
||||
router.tachyon.online = false;
|
||||
assert(context.renderTachyon(router).includes('Offline'));
|
||||
router.permissions.admin = false;
|
||||
assert(!context.renderTachyon(router).includes('<a '));
|
||||
router.permissions.admin = true; router.tachyon.version = '<img onerror=alert(1)>';
|
||||
assert(!context.renderTachyon(router).includes('<img '));
|
||||
assert.equal(source.split(String.fromCharCode(36) + '{{renderTachyon(r)}}').length - 1, 2);
|
||||
console.log('TACHYON_UI_OK: absent, installed, offline, access controls, escaping and both layouts');
|
||||
Reference in new issue
Block a user