Opened 15 years ago
Closed 15 years ago
#14164 closed (fixed)
Automatic localization of numbers (L10N) in templates can cause invalid sitemap priorities
| Reported by: | Mathijs de Bruin | Owned by: | nobody |
|---|---|---|---|
| Component: | Internationalization | Version: | 1.2 |
| Severity: | Keywords: | internationalization L10N sitemaps comma | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
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 = Trueinsettings.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.
Attachments (1)
Change History (9)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
comment:3 by , 15 years ago
| Has patch: | set |
|---|
comment:4 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:5 by , 15 years ago
comment:6 by , 15 years ago
Getting sitemaps working is a priority, so I've committed the str() based patch. However, I've also opened #14181 to track the larger issue of 'delocalized' template rendering.
comment:7 by , 15 years ago
| Patch needs improvement: | set |
|---|---|
| Resolution: | fixed |
| Status: | closed → reopened |
I have applied this patch on my django installation because i had the same problem.
But there is another problem, only with the GenericSitemap : when the priority is not specified, i have « None » in the priority field of the sitemap.
I think you have to modify the lines 84 and 87 of the same file, and change the default value of priority, from None to .
comment:8 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
@palkeo - I can't reproduce the behavior you describe. Defining a sitemap with no priority, or a priority that returns None (either as a class attribute or method) results in the priority field being omitted.
If you still think this is a bug, please open a *new* ticket with a specific test case -- preferably one using the newly provided test suite for the sitemaps app.
One workaround that seems to do the job (for now) is to use a string value as the priority.