[Bug]: Ampersand symbol not parsed correctly in description #598

Closed
opened 2026-04-24 23:14:14 +02:00 by adam · 7 comments
Owner

Originally created by @Jdiesel87 on GitHub (Aug 22, 2022).

Describe the issue

I'm not sure if this is a metadata source issue, I'm using the Audible provider, or a ABS issue but the ampersand symbol is being displayed as "& a m p ;" in the description.

Steps to reproduce the issue

Using the Audible provider search the book "I'm Glad My Mom Died" by Jennette McCurdy. The description will contain "& a m p ;" where it should be &

Audiobookshelf version

v2.1.4

How are you running audiobookshelf?

Docker

Originally created by @Jdiesel87 on GitHub (Aug 22, 2022). ### Describe the issue I'm not sure if this is a metadata source issue, I'm using the Audible provider, or a ABS issue but the ampersand symbol is being displayed as "& a m p ;" in the description. ### Steps to reproduce the issue Using the Audible provider search the book "I'm Glad My Mom Died" by Jennette McCurdy. The description will contain "& a m p ;" where it should be & ### Audiobookshelf version v2.1.4 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:14:14 +02:00
adam closed this issue 2026-04-24 23:14:14 +02:00
Author
Owner

@barrycarey commented on GitHub (Aug 29, 2022):

@advplyr This is coming from here

The process of stripping the tags also escapes certain characters (&, <, >, "). It doesn't appear there's a config option to sanitizeHtml that would prevent this. Something would have to be implemented to decode the HTML escapes.

@barrycarey commented on GitHub (Aug 29, 2022): @advplyr This is coming from [here](https://github.com/advplyr/audiobookshelf/blob/575ec9d00ba782a2e6716fcca1d22523a7068231/server/utils/htmlSanitizer.js#L26) The process of stripping the tags also escapes certain characters (&, <, >, "). It doesn't appear there's a config option to sanitizeHtml that would prevent this. Something would have to be implemented to decode the HTML escapes.
Author
Owner

@advplyr commented on GitHub (Aug 29, 2022):

@barrycarey ah okay. We can edit the sanitizeHtml library and just manually put in &amp; and any obvious ones.

@advplyr commented on GitHub (Aug 29, 2022): @barrycarey ah okay. We can edit the sanitizeHtml library and just manually put in \&amp; and any obvious ones.
Author
Owner

@barrycarey commented on GitHub (Aug 29, 2022):

Any issues with me adding a function to restore the common characters? Seems like that is the safer solution since the core lib won't be touched.

@barrycarey commented on GitHub (Aug 29, 2022): Any issues with me adding a function to restore the common characters? Seems like that is the safer solution since the core lib won't be touched.
Author
Owner

@advplyr commented on GitHub (Aug 30, 2022):

@barrycarey That's probably better actually, you could put that inside the htmlSanitizer.js util script.

@advplyr commented on GitHub (Aug 30, 2022): @barrycarey That's probably better actually, you could put that inside the `htmlSanitizer.js` util script.
Author
Owner

@barrycarey commented on GitHub (Aug 30, 2022):

@advplyr What do you think about adding another dependency? This would work

If not, I can still do a generic function to hit the most common html entities.

Let me know which route you'd rather take and I'll submit a PR

@barrycarey commented on GitHub (Aug 30, 2022): @advplyr What do you think about adding another dependency? [ This would work ](https://www.npmjs.com/package/html-entities) If not, I can still do a generic function to hit the most common html entities. Let me know which route you'd rather take and I'll submit a PR
Author
Owner

@advplyr commented on GitHub (Aug 30, 2022):

I want to avoid adding another dependency unless we have to. That library looks great though we can definitely use these mappings of HTML5 entities they put together.

We only need probably 5% of what that library offers so it ends up being a ton of extra code we don't use.

This only needs to be implemented in that stripAllTags function because that is expecting a plain text response, whereas the sanitize function returns HTML that will render the &amp; correctly. You probably already caught that but just wanted to make sure.

@advplyr commented on GitHub (Aug 30, 2022): I want to avoid adding another dependency unless we have to. That library looks great though we can definitely use [these](https://github.com/mdevils/html-entities/blob/master/src/named-references.ts#L645) mappings of HTML5 entities they put together. We only need probably 5% of what that library offers so it ends up being a ton of extra code we don't use. This only needs to be implemented in that `stripAllTags` function because that is expecting a plain text response, whereas the `sanitize` function returns HTML that will render the \&amp; correctly. You probably already caught that but just wanted to make sure.
Author
Owner

@advplyr commented on GitHub (Sep 5, 2022):

Fixed in v2.1.5

@advplyr commented on GitHub (Sep 5, 2022): Fixed in [v2.1.5](https://github.com/advplyr/audiobookshelf/releases/tag/v2.1.5)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#598