This commit is contained in:
TowyTowy 2026-07-10 06:51:24 +02:00 committed by GitHub
commit 2bd29ee6c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 2 deletions

View file

@ -1,6 +1,7 @@
const axios = require('axios').default
const Logger = require('../Logger')
const { isValidASIN } = require('../utils/index')
const htmlSanitizer = require('../utils/htmlSanitizer')
class Audible {
#responseTimeout = 10000
@ -66,8 +67,10 @@ class Audible {
}
return {
title,
subtitle: subtitle || null,
// Audible metadata can contain HTML entities (e.g. `"`, `&`) that are otherwise
// shown literally in titles/subtitles. Decode them at the ingestion boundary. See #5340
title: title ? htmlSanitizer.stripAllTags(title) : title,
subtitle: subtitle ? htmlSanitizer.stripAllTags(subtitle) : null,
author: authors ? authors.map(({ name }) => name).join(', ') : null,
narrator: narrators ? narrators.map(({ name }) => name).join(', ') : null,
publisher: publisherName,

View file

@ -45,4 +45,22 @@ describe('Audible', () => {
expect(result).to.equal('.5')
})
})
describe('cleanResult', () => {
it('should decode HTML entities in the title and subtitle (#5340)', () => {
const result = audible.cleanResult({
title: 'The "Hitler" Myth',
subtitle: 'Image & Reality in the Third Reich',
asin: 'B0TESTASIN'
})
expect(result.title).to.equal('The "Hitler" Myth')
expect(result.subtitle).to.equal('Image & Reality in the Third Reich')
})
it('should keep a null subtitle when none is provided', () => {
const result = audible.cleanResult({ title: 'A Plain Title', asin: 'B0TESTASIN' })
expect(result.title).to.equal('A Plain Title')
expect(result.subtitle).to.equal(null)
})
})
})