~ubuntu-branches/ubuntu/oneiric/python-django/oneiric

« back to all changes in this revision

Viewing changes to django/utils/http.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2011-02-17 13:34:07 UTC
  • mfrom: (1.1.13 upstream) (4.4.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110217133407-rwr88elhhq6j7ba0
Tags: 1.2.5-1ubuntu1
* Merge from Debian for security fixes (LP: #719031). Remaining changes:
  - debian/control: don't Build-Depends on locales-all, which doesn't exist
    in natty
* Drop the following patches, now included upstream:
  - debian/patches/07_security_admin_infoleak.diff
  - debian/patches/08_security_pasword_reset_dos.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import re
 
2
import sys
2
3
import urllib
3
4
from email.Utils import formatdate
4
5
 
73
74
 
74
75
def base36_to_int(s):
75
76
    """
76
 
    Converts a base 36 string to an ``int``. To prevent
77
 
    overconsumption of server resources, raises ``ValueError` if the
78
 
    input is longer than 13 base36 digits (13 digits is sufficient to
79
 
    base36-encode any 64-bit integer).
 
77
    Converts a base 36 string to an ``int``. Raises ``ValueError` if the
 
78
    input won't fit into an int.
80
79
    """
 
80
    # To prevent overconsumption of server resources, reject any
 
81
    # base36 string that is long than 13 base36 digits (13 digits
 
82
    # is sufficient to base36-encode any 64-bit integer)
81
83
    if len(s) > 13:
82
84
        raise ValueError("Base36 input too large")
83
 
    return int(s, 36)
 
85
    value = int(s, 36)
 
86
    # ... then do a final check that the value will fit into an int.
 
87
    if value > sys.maxint:
 
88
        raise ValueError("Base36 input too large")
 
89
    return value
84
90
 
85
91
def int_to_base36(i):
86
92
    """