1 parent
6213fec7d2
commit
fdbc9a9d1b
7 files changed
+598
-2
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { newRegistryEntry, renderRegistryEditor } from '../src/registry-editor.ts';
|
||||
|
||||
test('new entries select the app view and preserve lossless text data', () => {
|
||||
assert.equal(newRegistryEntry('x86', 'one').view, '32');
|
||||
const entry = newRegistryEntry('x64', 'two');
|
||||
entry.valueType = 'REG_QWORD'; entry.data = '18446744073709551615';
|
||||
assert.match(renderRegistryEditor([entry], false), /18446744073709551615/);
|
||||
assert.equal(JSON.parse(JSON.stringify(entry)).data, entry.data);
|
||||
});
|
||||
test('registry editor escapes markup and addresses rows after deletion', () => {
|
||||
const first = newRegistryEntry('x64', 'first');
|
||||
const second = newRegistryEntry('x64', 'second');
|
||||
second.data = '</textarea><script>alert(1)</script>';
|
||||
second.name = '" onfocus="bad';
|
||||
const entries = [first, second]; entries.splice(0, 1);
|
||||
const html = renderRegistryEditor(entries, true);
|
||||
assert.ok(!html.includes('<script>'));
|
||||
assert.ok(html.includes('</textarea>'));
|
||||
assert.ok(html.includes('" onfocus="bad'));
|
||||
assert.ok(html.includes('registry.0.data'));
|
||||
assert.ok(html.includes('data-action="registry-remove:0" disabled'));
|
||||
});
|
||||
Reference in new issue
Block a user