~lifeless/python-oops-tools/bug-881400

« back to all changes in this revision

Viewing changes to src/oopstools/oops/models.py

  • Committer: Robert Collins
  • Date: 2011-10-31 02:07:24 UTC
  • mfrom: (6.2.2 python-oops-tools)
  • Revision ID: robertc@robertcollins.net-20111031020724-1itg2mas5r16bk21
Updated version of Roman's bad-url fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
371
371
        # We have gotten a ringer, URL's are bytestrings. Encode to UTF8 to get
372
372
        # a bytestring and urllib.quote to get a url.
373
373
        url = urllib.quote(url.encode('utf8'))
 
374
    else:
 
375
        try:
 
376
            url.decode('ascii')
 
377
        except UnicodeDecodeError:
 
378
            # The URL is not ASCII and thus definitely not a URL.
 
379
            # There may be a byte in local encoding or it may be UTF8 - we need
 
380
            # to quote it to make it a valid URL - this is better than
 
381
            # rejecting the OOPS, or having a URL that isn't in the DB.
 
382
            url = urllib.quote(url)
 
383
 
374
384
    informational = oops.get('informational', 'False').lower() == 'true'
375
385
    oops_date = oops.get('time')
376
386
    if oops_date is None: