craft-seomatic icon indicating copy to clipboard operation
craft-seomatic copied to clipboard

German Umlauts in links not correctly encoded

Open vitus-prediger opened this issue 4 months ago • 2 comments

Describe the bug

German umlauts not correctly encoded in loc URLS.

To reproduce

Steps to reproduce the behaviour:

  1. Go to our blog-3-sitemap.xml
  2. Search for prediger-zu-besuch-bei-sattler and check the URL in <image:loc>
  3. See that it contains Körner

Expected behaviour

To avoid confusion and parsing errors, german umlauts should be % encoded in all sitemap URLs.

Technical details

In the file helpers/Sitemap.php:592 $asset->getUrl() already returns the correctly encoded URL for the asset which gets run through UrlHelper::absoluteUrlWithProtocol() which in turns calls TextHelper::sanitizeUserInput() down the line and rawurldecode's the URL again in helpers/Text.php:340. That removes the % encoding again.

Screenshots

Image

Versions

  • Plugin version: dev-develop-v5 as 5.1.13
  • Craft version: 5.8.15

vitus-prediger avatar Nov 06 '25 09:11 vitus-prediger

IF you run your sitemap through a sitemap validator, does it present you with any errors?

e.g.:

https://www.xml-sitemaps.com/validate-xml-sitemap.html

https://validator.w3.org/

...or when looking in your Google Search Console, does it report any errors with the sitemap in question?

khalwat avatar Nov 06 '25 21:11 khalwat

@khalwat No, they do not give any errors. It's just that our SEO audit recommended having all non-ASCII characters encoded according to RFC-3986 to avoid potential errors with older crawlers.

Maybe you could add an option in the Sitemap settings for that?

vitus-prediger avatar Nov 07 '25 09:11 vitus-prediger

So this is probably something I should fix. All modern browsers/platforms handle umlats in URLs properly, but some very old legacy systems may not.

khalwat avatar Dec 12 '25 22:12 khalwat

@khalwat Thanks for responding. We took care of it in the meantime by renaming the files. But I do agree with you, if not only for compatibility reasons, but also for future occurrences.

vitus-prediger avatar Dec 15 '25 07:12 vitus-prediger