mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-12 12:21:34 +00:00
Decode HTML entities in Audible title and subtitle
Audible/audnex metadata can contain HTML entities such as `"` and `&` that were passed through untouched, so titles like `The "Hitler" Myth` were displayed literally instead of `The "Hitler" Myth`. Decode the entities at the ingestion boundary in `cleanResult` using the existing `htmlSanitizer.stripAllTags` helper (the same plain-text treatment already used for collection/playlist names). This decodes once, avoiding the double-decoding of legitimate literal entities. Fixes #5340 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
6f03467f35
commit
98e1e5a29a
2 changed files with 23 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue