sitemap-module icon indicating copy to clipboard operation
sitemap-module copied to clipboard

image caption is always wrapped in CDATA in the output xml

Open jd1378 opened this issue 5 years ago • 5 comments

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

This bug report is available on Nuxt community (#c75)

jd1378 avatar Jan 08 '20 23:01 jd1378

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 :-/

NicoPennec avatar Jan 09 '20 08:01 NicoPennec

@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 ?

jd1378 avatar Jan 21 '20 08:01 jd1378

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 ?

jd1378 avatar Jan 21 '20 08:01 jd1378

I created #100 pull request on this matter.

jd1378 avatar Jan 21 '20 12:01 jd1378

any updates on cdata? i'm facing this cdata in news. my news data are :

        news: {
            publication: {
              name: 'সময় নিউজ',
              language: process.env.NEWS_LANG
            },
            publication_date: new Date(parseInt(news.updatedAt)).toISOString(),
            title: news.title
          }

but its showing like this in sitemap

<url>
  <loc>http://somoy.test:5001/news/2-24-2021/what-is-lorem-ipsum-</loc>
   <news:news>
    <news:publication>
      <news:name>
        <![CDATA[ সময় নিউজ ]]>
      </news:name>
      <news:language>bn</news:language>
    </news:publication>
    <news:publication_date>2021-02-24T07:27:53.436Z</news:publication_date>
    <news:title>
      <![CDATA[ 2.What is Lorem Ipsum? ]]>
    </news:title>
  </news:news>
</url>

mimbo119 avatar May 24 '21 14:05 mimbo119