iamvishnusankar / next-sitemap

Sitemap generator for next.js. Generate sitemap(s) and robots.txt for all static/pre-rendered/dynamic/server-side pages.
https://next-sitemap.iamvishnusankar.com
MIT License
3.17k stars 120 forks source link

If a character string such as a pictogram that is not allowed according to the XML standard is entered, it will be output as is to the site map and invalid XML will be generated. #814

Open mecaota opened 1 month ago

mecaota commented 1 month ago

Describe the bug

If input like a 🌞Sun is rising🌞 word, it is include emoji(XML standard is not allowed characters), export invalid XML.

If these are entered, an error should occur internally, or the invalid string should be deleted. Otherwise, invalid XML will be generated.

To Reproduce

This is app router. Maybe page router too.

Steps to reproduce the behavior:

  1. In the sitemap route.tsx|jsx, write below code.
    export async function GET() {
    return getServerSideSitemap([
    {
      loc: 'https://example.com',
      images: [
        {
          title: '🌞Sun is rising🌞',
          loc: new URL('https://example.com'),
        },
      ],
    },
    ]);
    } 
  2. Access sitemap route via Google Chrome.
  3. Error throwed the below.
    This page contains the following errors:
    error on line 3 at column 113: xmlParseCharRef: invalid xmlChar value 55356
    Below is a rendering of the page up to the first error.

Expected behavior

An error message indicating that an invalid string has been entered, or the string is replaced with an empty string (it is desirable to have an option for this)

Screenshots

error

スクリーンショット 2024-05-22 15 54 56

expected

スクリーンショット 2024-05-22 16 00 51

Additional context