Revert "try to replace html sniffing with chardet to fix ncc.html files with set encoding but strings that ignore that"

This reverts commit 3a1be51a83.

Revert "try to properly interpret ncc.html encoding (seems to be a bit weird / incorrect sometimes)"

This reverts commit fac4415595.
This commit is contained in:
Toni Barth 2026-02-08 03:33:56 +01:00
parent b05acce22b
commit 52a0b61b97
5 changed files with 3 additions and 120 deletions

View file

@ -6,26 +6,6 @@ const fs = require('fs')
const Logger = require('../../../server/Logger')
describe('fileUtils', () => {
describe('decodeTextBuffer', () => {
it('decodes html using charset declaration (windows-1252)', () => {
const htmlPrefix = Buffer.from('<html><head><meta charset="windows-1252"></head><body>M')
const htmlSuffix = Buffer.from('ller</body></html>')
const input = Buffer.concat([htmlPrefix, Buffer.from([0xfc]), htmlSuffix])
const decoded = fileUtils.decodeTextBuffer(input, { detectEncoding: true, isHtml: true })
expect(decoded).to.include('Müller')
})
it('falls back to windows-1252 for html without charset when utf-8 decoding is invalid', () => {
const htmlPrefix = Buffer.from('<html><body>Gr')
const htmlSuffix = Buffer.from('n</body></html>')
const input = Buffer.concat([htmlPrefix, Buffer.from([0xfc]), htmlSuffix])
const decoded = fileUtils.decodeTextBuffer(input, { detectEncoding: true, isHtml: true })
expect(decoded).to.include('Grün')
})
})
it('shouldIgnoreFile', () => {
global.isWin = process.platform === 'win32'