image caption is always wrapped in CDATA in the output xml

jd1378
0
jd1378
commented 5 months ago

Version

2.0.1

Reproduction link

https://codesandbox.io/s/epic-chatterjee-pnzlr

Steps to reproduce

use image with a caption in a route

What is expected ?

<url>
  <loc>https://examplee.com/</loc>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
  <image:image>
    <image:loc>https://example.com/some-image.png</image:loc>
    <image:caption>normal string</image:caption>
  </image:image>
</url>

What is actually happening?

<url>
  <loc>https://examplee.com/</loc>
  <changefreq>weekly</changefreq>
  <priority>0.8</priority>
  <image:image>
    <image:loc>https://example.com/some-image.png</image:loc>
    <image:caption><![CDATA[normal string]]></image:caption>
  </image:image>
</url>

Additional comments?

And i don't know why my sandbox does not even generate the xml file properly anyway.
I tried setting "cdata" to false in sitemap options defaults but it didn't help.
I have tested the route example in the sandbox on my local environment and it got wrapped in cdata

bug
0
NicoPennec
1.9k
NicoPennec
commented 5 months ago

It's not an issue, but a feature from the sitemap.js lib to secure by default your XML content of element, because all HTML entities should be escaped or wrapped in a CDATA block.

So your XML still a valid sitemap: https://www.xml-sitemaps.com/validate-xml-sitemap.html?op=validate-xml-sitemap&go=1&sitemapurl=https%3A%2F%2Fpnzlr.sse.codesandbox.io%2Fsitemap.xml&submit=Validate+Sitemap

The cdata: false option had an issue on sitemap.js v4 and should be fixed on v5 (see https://github.com/ekalinin/sitemap.js/issues/245). But currently the sitemap-module cannot bump to v5 due to a breaking change :-/

0
jd1378
0
jd1378
commented 4 months ago

@NicoPennec
If the tests currently in project are written good, then bumping to v5 is easy, as it seems the tests only fail on xslUrl option and mobile sitemap which both are dropped, then modifying the tests to exclude those would be easy
and they don't seem like a huge deal to me at least

the more important feature is the v5's streams to be implemented in a way to generate sitemaps without using much memory which is another discussion, so can you explain why we cannot bump to v5 ?

0
jd1378
0
jd1378
commented 4 months ago

I think the only issue regarding xslUrl is #58 which only asks to add what's already in sitemap.js, which is not anymore, so I guess we are okay about that ?

0
jd1378
0
jd1378
commented 4 months ago

I created #100 pull request on this matter.

0
Informations
Bug Report โ€ข Open
#c75 - Created 5 months ago