Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on sitemap.xml for demo #613

Closed
hydropik opened this issue Mar 2, 2023 · 2 comments · Fixed by #662
Closed

Error on sitemap.xml for demo #613

hydropik opened this issue Mar 2, 2023 · 2 comments · Fixed by #662

Comments

@hydropik
Copy link

hydropik commented Mar 2, 2023

What is the location of your example repository?

No response

What version of Hydrogen are you using?

latest

What version of Remix are you using?

latest

Steps to Reproduce

The error append when the charter "&" is used in the title of a product.

Expected Behavior

A normal preview of sitemap.xml

Actual Behavior

A parsing error appear in the browser when we go on sitemap.xml page

This page contains the following errors:
error on line 243 at column 41: xmlParseEntityRef: no name
Below is a rendering of the page up to the first error.

@hydropik
Copy link
Author

hydropik commented Mar 2, 2023

not sur if it's the best solution but I add this function

https://github.com/Shopify/hydrogen/blob/2023-01/templates/demo-store/app/routes/%5Bsitemap.xml%5D.tsx

function htmlEncode(text: String) {
  text.replace(/[\u00A0-\u9999<>\&]/g, function(i) {
    return '&#'+i.charCodeAt(0)+';';
  });

  return '';
}

and

finalObject.image.title` = htmlEncode(product.title);

on line 75

@frandiox
Copy link
Contributor

frandiox commented Mar 8, 2023

Thanks! This will be fixed in #662

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 a pull request may close this issue.

2 participants