UnicodeDecodeError in python3 module with binary input

Aren Sandersen aren at foxpass.com
Wed Dec 6 23:02:24 UTC 2023


We have a commit that adds a configuration flag so that anything that can't
be interpreted as UTF-8 will be a binary string instead. I'll submit it as
a PR.

Aren


> while using the python3 module with 3.2.1 I got the following errors:
>
> mod_populate_vptuple:402, vp->da->name: User-Password
> python_error_log:209, Exception type: <class 'UnicodeDecodeError'>,
> Exception value: 'utf-8' codec can't decode byte 0xb3 in position 0:
> invalid start byte
> do_python_single:496, authorize - mod_populate_vps failed
> do_python_single:675, authorize - RLM_MODULE_FAIL
>
> The cause is a switch whichs software mangles the User-Password to binary
> garbage.
>
> Is this handling of binary values in the python module favorable? To my
> feeling it would be
> cleaner to convert to bytes (instead of a string). Then python can handle
> binary data well.
>
> Or make the conversion using replacement character/ignoring encoding
> errors.
>
> The switch will be fixed, so this is only a design question.
>
> Thanks for all your great work,
> greetings
>   Hermann
>


More information about the Freeradius-Users mailing list