Changes between Initial Version and Version 1 of Ticket #34891


Ignore:
Timestamp:
Oct 5, 2023, 7:11:52 PM (12 months ago)
Author:
Tim Graham
Comment:

Hi Jeff, it's unclear that Django is at fault here. It looks like the uidb64 value isn't correct for what this code is trying to do. See TicketClosingReasons/UseSupportChannels if you need help debugging your issue, and reopen the ticket if you can explain why Django is at fault. Thanks!

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34891

    • Property Resolutionneedsinfo
    • Property Status newclosed
  • Ticket #34891 – Description

    initial v1  
    1 Trying to decode:
     1{{{ #!pycon
     2>>> from django.utils.encoding import force_str
     3>>> from django.utils.http import urlsafe_base64_decode
     4>>> uidb64 = 'PHByb3BlcnR5IG9iamVjdCBhdCAweDAwMDAwMjU1M0ZBNTlEQTA-bvlp6u-9b15d1fd6d30b90e81623812e9bc8d74'
     5>>> result = urlsafe_base64_decode(uidb64)
     6>>> result
     7b'<property object at 0x000002553FA59DA0>n\xf9i\xea\xef\xbdo^]\xd5\xf7zw}\x1b\xf7G\xbc\xd7\xad\xb7\xf3]\x9e\xf5\xb7<w\xbe'
    28
    3 PHByb3BlcnR5IG9iamVjdCBhdCAweDAwMDAwMjU1M0ZBNTlEQTA-
    4 bvlp6u-9b15d1fd6d30b90e81623812e9bc8d74
     9>>> force_str(result)
     10Traceback (most recent call last):
     11  File "/home/tim/code/django/django/utils/encoding.py", line 70, in force_str
     12    s = str(s, encoding, errors)
     13UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 40: invalid start byte
    514
    6 force_str(urlsafe_base64_decode(uidb64)) returns:
     15During handling of the above exception, another exception occurred:
    716
    8 Field 'id' expected a number but got b'<property object at 0x000002553FA59DA0>'.
    9 
    10 The above exception (invalid literal for int() with base 10: b'<property object at 0x000002553FA59DA0>') was the direct cause of the following exception:
     17Traceback (most recent call last):
     18  File "<console>", line 1, in <module>
     19  File "/home/tim/code/django/django/utils/encoding.py", line 74, in force_str
     20    raise DjangoUnicodeDecodeError(s, *e.args)
     21django.utils.encoding.DjangoUnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 40: invalid start byte. You passed in b'<property object at 0x000002553FA59DA0>n\xf9i\xea\xef\xbdo^]\xd5\xf7zw}\x1b\xf7G\xbc\xd7\xad\xb7\xf3]\x9e\xf5\xb7<w\xbe' (<class 'bytes'>)
     22}}}
    1123
    1224Code:
    13 
     25{{{ #!python
    1426def activate(request, uidb64, token):
    1527    try:
     
    2739    else:
    2840        return HttpResponseBadRequest('Activation link is invalid!')
     41}}}
Back to Top