#35627 closed Bug (fixed)
LocaleMiddleware does not handle ValueError 'lang_code' exceeds the maximum accepted length
| Reported by: | Lorenzo Peña | Owned by: | Lorenzo Peña |
|---|---|---|---|
| Component: | Internationalization | Version: | 5.0 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Try any Django powered site where LocaleMiddleware is enanled and visit domain.com/aaaaaaaaaaa.... (where there are 1000 'a').
This line kicks in: https://github.com/django/django/blob/main/django/utils/translation/trans_real.py#L520
I think the outcome should be a 404 instead of raising ValueError all the way up.
Change History (10)
comment:1 by , 16 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , 16 months ago
| Has patch: | set |
|---|
comment:3 by , 16 months ago
| Component: | Uncategorized → Internationalization |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Bug |
comment:4 by , 16 months ago
I'd be happy to break the ice with Django contributions with this one, if possible. In the PR I am catching both ValueError and LookupError in the callers. I am happy to also raise LookupError instead and not modify anything else.
comment:6 by , 16 months ago
| Summary: | LocaleMiddleware: 'lang_code' exceeds the maximum accepted length → LocaleMiddleware does not handle ValueError 'lang_code' exceeds the maximum accepted length |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Regression in 9e9792228a6bb5d6402a5d645bc3be4cf364aefb
Perhaps we should raise a LookupError rather than a ValueError, I believe this needs backporting to 4.2, 5.0, 5.1