Automatic localization of numbers (L10N) in templates can cause invalid sitemap priorities
|Reported by:||dokterbob||Owned by:||nobody|
|Severity:||Keywords:||internationalization L10N sitemaps comma|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
When specifying priorities for a sitemap as a float (as is suggested by the official documentation) and USE_L10N = True, it can happen that requested sitemaps contain comma's in the priority values for items when the server detects certain locales. As the sitemaps specification requires a dot as a separator for float values this yields an invalid sitemap and has been confirmed to prohibit the indexing of certain sites.
The problem can be reproduced as follows:
- Make sure USE_L10N = True in settings.py.
- Create a Sitemap object with a priority and expose it somewhere in the URL space. (For example: priority = 0.5)
- Request the sitemap with a browser for which the decimal separator is something other than a dot. (This holds for many European locales.)
- Priority value should now be rendered wrongly. (For example: <priority>0,5</priority>)
As this problem is likely to occur for other situations where templates are used to render machine-parseable content, a structural solution should be in order.
Change History (9)
comment:1 Changed 5 years ago by dokterbob
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
Changed 5 years ago by vung
comment:7 Changed 5 years ago by palkeo
- Patch needs improvement set
- Resolution fixed deleted
- Status changed from closed to reopened