mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-03 14:39:41 +00:00
Revert "try to replace html sniffing with chardet to fix ncc.html files with set encoding but strings that ignore that"
This reverts commit3a1be51a83. Revert "try to properly interpret ncc.html encoding (seems to be a bit weird / incorrect sometimes)" This reverts commitfac4415595.
This commit is contained in:
parent
b05acce22b
commit
52a0b61b97
5 changed files with 3 additions and 120 deletions
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue