Render native PowerShell CP850 output with an explicit decoding choice
This commit is contained in:
@@ -37,3 +37,32 @@ it('shows unknown restart state for an incomplete Windows Update summary', () =>
|
||||
expect(rendered(windowsUpdateScriptHash)).toContain('Neustartbedarf: unknown');
|
||||
expect(rendered('ordinary script')).toContain('Neustartbedarf: false');
|
||||
});
|
||||
|
||||
|
||||
it('decodes native PowerShell CP850 umlauts while preserving raw bytes and control escapes', () => {
|
||||
const raw = outputBytes([132, 148, 129, 142, 153, 154, 225, 13, 10, 27]);
|
||||
const original = Array.from(raw);
|
||||
expect(outputText(raw, 'powershell').text).toBe('äöüÄÖÜß\\u000d\n\\u001b');
|
||||
expect(outputText(raw, 'powershell').encoding).toContain('Quellcodepage nicht separat belegt');
|
||||
expect(outputText(raw, 'utf-8').text).toContain('�');
|
||||
expect(Array.from(raw)).toEqual(original);
|
||||
expect(outputText(outputBytes([156, 255]), 'cp850').text).toBe('£ ');
|
||||
});
|
||||
|
||||
it('keeps valid UTF-8 PowerShell output and generic invalid UTF-8 on their existing paths', () => {
|
||||
const raw = new TextEncoder().encode('Grüße äöüÄÖÜß');
|
||||
expect(outputText(raw, 'powershell').text).toBe('Grüße äöüÄÖÜß');
|
||||
expect(outputText(outputBytes([148])).text).toBe('�');
|
||||
});
|
||||
|
||||
it('selects the native PowerShell text view only from matching result evidence', () => {
|
||||
const result = { stdout: [98, 148, 115, 97, 114, 116, 105, 103], stderr: [], evidence: {interpreter:'powershell',output_encoding:'raw_native_bytes'} };
|
||||
const before = JSON.stringify(result);
|
||||
const html = renderToStaticMarkup(<ConsoleOutput job={{state:'succeeded',attempt_id:'test',result}}/>);
|
||||
expect(html).toContain('bösartig');
|
||||
expect(html).toContain('stdout Textdekodierung');
|
||||
expect(html).toContain('Windows OEM 850');
|
||||
expect(JSON.stringify(result)).toBe(before);
|
||||
const other = renderToStaticMarkup(<ConsoleOutput job={{result:{...result,evidence:{interpreter:'posix_sh',output_encoding:'raw_native_bytes'}}}}/>);
|
||||
expect(other).not.toContain('bösartig');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user