mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-12 20:31:36 +00:00
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>
66 lines
No EOL
2.3 KiB
JavaScript
66 lines
No EOL
2.3 KiB
JavaScript
const Audible = require('../../../server/providers/Audible')
|
|
const { expect } = require('chai')
|
|
const sinon = require('sinon')
|
|
|
|
describe('Audible', () => {
|
|
let audible;
|
|
|
|
beforeEach(() => {
|
|
audible = new Audible();
|
|
});
|
|
|
|
describe('cleanSeriesSequence', () => {
|
|
it('should return an empty string if sequence is falsy', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', null)
|
|
expect(result).to.equal('')
|
|
})
|
|
|
|
it('should return the sequence as is if it does not contain a number', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', 'part a')
|
|
expect(result).to.equal('part a')
|
|
})
|
|
|
|
it('should return the sequence as is if contains just a number', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', '2')
|
|
expect(result).to.equal('2')
|
|
})
|
|
|
|
it('should return the sequence as is if contains just a number with decimals', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', '2.3')
|
|
expect(result).to.equal('2.3')
|
|
})
|
|
|
|
it('should extract and return the first number from the sequence', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', 'Book 1')
|
|
expect(result).to.equal('1')
|
|
})
|
|
|
|
it('should extract and return the number with decimals from the sequence', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', 'Book 1.5')
|
|
expect(result).to.equal('1.5')
|
|
})
|
|
|
|
it('should extract and return the number even if it has no leading zero', () => {
|
|
const result = audible.cleanSeriesSequence('Series Name', 'Book .5')
|
|
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)
|
|
})
|
|
})
|
|
}) |