Skip to content

fix(rss): emit podcast categories as text attributes - #261

Open
cpruijsen wants to merge 1 commit into
jpmonette:mainfrom
cpruijsen:fix/issue-229
Open

cpruijsen wants to merge 1 commit into
jpmonette:mainfrom
cpruijsen:fix/issue-229

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Summary

  • Fixes iTunes Category has invalid format聽#229: with podcast: true and category: "History", RSS 2.0 now emits <itunes:category text="History"/> (and the same shape for googleplay:category) instead of <itunes:category>History</itunes:category>.
  • Provenance: reported by @UnprofessionalMartin on feed 5.1.0 against Apple's RSS guide. Still reproduced on current main. xml-js compact mode treats a raw string as element text; both podcast category tags were assigned that way in one block.
  • Category text goes through existing sanitize() so names like Society & Culture become text="Society &amp; Culture". xml-js does not escape & in attributes (same workaround as fix(atom): escape & in category attribute values聽#249 for Atom categories). Nested iTunes subcategories are not added; FeedOptions.category is still a single string.

Decision

  • Chose: _attributes: { text } for both iTunes and Google Play, plus sanitize().
  • Alternative: change only itunes:category; leave Google Play as element text; skip sanitizing because the reporter's example was History.
  • Why: both tags were one assignment. Google Play's schema requires a text attribute on category. Apple's guide requires escaping ampersands, and several official category names contain &. xml-js will not escape those once the value is an attribute.
  • Happy to drop the Google Play change or the sanitizer if you want this limited to the iTunes element shape.

xml-js emits a self-closing tag with no space before />. Apple's examples include a space. That is equivalent XML; this renderer already serializes empty elements that way.

Test plan

  • pnpm test src/__tests__/rss2.spec.ts, new tests fail without the renderer change and pass with it
  • pnpm test, 31 tests pass; existing podcast snapshot unchanged (it never set options.category)
  • pnpm lint and pnpm format clean on src

Apple and Google Play both require the category name as a text
attribute. xml-js was given a raw string, so it emitted element text
instead, and does not escape & in attributes on its own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iTunes Category has invalid format

1 participant