develooper Front page | perl.perl5.porters | Postings from March 2021

Re: Perl 7: Fix string leaks?

Thread Previous
From:
Dan Book
Date:
March 29, 2021 00:21
Subject:
Re: Perl 7: Fix string leaks?
Message ID:
CABMkAVXOuGpAv5GTabMD+nuPzN477cYZJf7RdVzOMPDwq11wxg@mail.gmail.com
On Sun, Mar 28, 2021 at 8:13 PM Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

> Does this mean that mkdir can be allowed to pass a string that has UTF8
> flag?
>
> Currently, I think that the correct behavior of Perl5 is that the bytes
> are passed to mkdir.
>
> For example, bytes means cp932 in windows, or UTF-8 in Mac or Linux/UNIX.
>

The problem is that the internal Perl storage of the string is passed,
which may or may not be the bytes you see in Perl (e.g. using length(), eq,
regex, other string operations) depending on operations that Perl users
should not care about. So you cannot be certain that the bytes you intended
to pass will be used. Further explained in Felipe's recent blog post:
https://dev.to/fgasper/use-sys-binmode-4e6o

-Dan

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About