UTF-8-challenged checkpatch on patchwork
Toke Høiland-Jørgensen
toke at redhat.com
Wed Dec 2 08:24:58 AEDT 2020
Konstantin Ryabitsev <konstantin at linuxfoundation.org> writes:
> On Tue, Dec 01, 2020 at 10:36:43AM -0800, Jakub Kicinski wrote:
>> > Not sure if this is a bug in requests or not, but the corruption is
>> > introduced in .text. Here's POC:
>> >
>> > ----
>> > #!/usr/bin/env python3
>> > import requests
>> >
>> > pmbx = 'https://patchwork.kernel.org/project/netdevbpf/patch/20201130183705.17540-1-toke@redhat.com/mbox/'
>> > res = requests.get(pmbx)
>> >
>> > print('content: ' + res.content.decode().split('\n')[102])
>> > print(' text: ' + res.text.split('\n')[102])
>> > ----
>> >
>> > $ python3 test.py
>> > content: Signed-off-by: Toke Høiland-Jørgensen <toke at redhat.com>
>> > text: Signed-off-by: Toke Høiland-Jørgensen <toke at redhat.com>
>>
>> Ah, great! Thank you! I pushed out a patch, I will put it in prod after
>> the mid-day rush is over.
>
> Following up, this is not a bug in requests, but a bug in patchwork.
> Here are the headers it sends:
>
> $ wget -S https://patchwork.kernel.org/project/netdevbpf/patch/20201130183705.17540-1-toke@redhat.com/mbox/
> --2020-12-01 13:45:02-- https://patchwork.kernel.org/project/netdevbpf/patch/20201130183705.17540-1-toke@redhat.com/mbox/
> Resolving patchwork.kernel.org (patchwork.kernel.org)... 198.145.29.83
> Connecting to patchwork.kernel.org (patchwork.kernel.org)|198.145.29.83|:443... connected.
> HTTP request sent, awaiting response...
> HTTP/1.1 200 OK
> Server: nginx
> Date: Tue, 01 Dec 2020 18:45:03 GMT
> Content-Type: text/plain
> Content-Length: 6151
> Connection: keep-alive
> Content-Disposition: attachment; filename=net-inet_ecn-Fix-endianness-of-checksum-update-when-setting-ECT-1.patch
> X-Frame-Options: SAMEORIGIN
> proxy_redirect: off
>
> The HTTP/1.1 standard defines the default character encoding as
> iso-8859-1, so response.text is not wrong. Patchwork should be setting
> the correct encoding in the header to be utf-8:
>
> Content-Type: text/plain; charset=utf-8
>
> (here: https://github.com/getpatchwork/patchwork/blob/master/patchwork/views/patch.py#L157)
>
> Since it is, in fact, always utf-8:
>
> https://github.com/getpatchwork/patchwork/blob/master/patchwork/views/utils.py#L117
>
> I don't have time to submit a proper patch, so I'm just cowardly cc'ing
> the patchwork list in hopes that either someone does it for me, or that
> I remember to do it at some later point. :)
Seeing as you already did all the hard work:
https://github.com/getpatchwork/patchwork/pull/387
-Toke
More information about the Patchwork
mailing list