Encode "+" characters in sitemap URLs
authorThierry Florac <tflorac@ulthar.net>
Wed, 09 Jan 2019 10:18:36 +0100
changeset 355 a9ecbf6ad7ed
parent 354 5ca9b0d569a5
child 356 c00a39cd7f01
Encode "+" characters in sitemap URLs
src/pyams_default_theme/features/sitemap/templates/root-sitemap.pt
src/pyams_default_theme/features/sitemap/templates/tool-sitemap.pt
--- a/src/pyams_default_theme/features/sitemap/templates/root-sitemap.pt	Wed Jan 09 10:18:00 2019 +0100
+++ b/src/pyams_default_theme/features/sitemap/templates/root-sitemap.pt	Wed Jan 09 10:18:36 2019 +0100
@@ -2,7 +2,7 @@
 <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 	<tal:loop repeat="(ts, source) view.sources">
 		<sitemap>
-			<loc>${tales:absolute_url(source)}/sitemap.xml</loc>
+			<loc tal:define="source_url tales:absolute_url(source)">${source_url.replace('+', '%2B')}/sitemap.xml</loc>
 			<lastmod>${ts}</lastmod>
 		</sitemap>
 	</tal:loop>
--- a/src/pyams_default_theme/features/sitemap/templates/tool-sitemap.pt	Wed Jan 09 10:18:00 2019 +0100
+++ b/src/pyams_default_theme/features/sitemap/templates/tool-sitemap.pt	Wed Jan 09 10:18:36 2019 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 	<url tal:repeat="(lang, content) view.contents">
-		<loc tal:define="url tales:canonical_url(content)">${url}?lang=${lang}</loc>
+		<loc tal:define="url tales:canonical_url(content)">${url.replace('+', '%2B')}?lang=${lang}</loc>
 		<lastmod>${tales:timestamp(content, 'iso')}</lastmod>
 	</url>
 </urlset>