nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.22k stars 5.29k forks source link

Meta description is not being HTML decoded when writing meta tags #6938

Closed nealculiner closed 10 months ago

nealculiner commented 10 months ago

nopCommerce version: 4.60.5

Steps to reproduce the problem:

I have a product short description of:

Airline Pilot's Daily Aviation Logbook - the only complete CFR Part 117 app built by airline pilots for airline pilots

When viewing the meta description it shows:

<meta name="description" content="Airline Pilot&#x27;s Daily Aviation Logbook - the only complete CFR Part 117 app built by airline pilots for airline pilots" />

I'm not sure what other SEO fields are affected but this is one of them as I'm building out my new store and noticed this.

nealculiner commented 10 months ago

I looked at the source and it appears you're using _htmlEncoder.Encode on the meta tag writing which should not be encoded. This probably affects more than the description and other header writes should be reviewed as I see encoding in other areas as well such as keywords. I changed the code below and it fixed it for me.

Line 287 of NopHtmlHelper.cs

//return new HtmlString(_htmlEncoder.Encode(result ?? string.Empty)); return new HtmlString(result ?? string.Empty);

RomanovM commented 10 months ago

Duplicate of #5675