Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Use of strings with code points over 0xFF as arguments to "vec"
Browse files Browse the repository at this point in the history
Implement scheduled fatalization.  Adapt existing tests in t/op/vec.t.
Eliminate t/lib/warnings/doop and move one test to t/op/vec.t.

Document this fatalization in perldiag and perlfunc.

Documentation improvement recommended by Karl Williamson.

For: RT # 134139
(cherry picked from commit da5a0da)
  • Loading branch information
jkeenan authored and rurban committed Aug 10, 2020
1 parent beab5ca commit b75e4ca
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 37 deletions.
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -6634,7 +6634,6 @@ t/lib/warnings/9enabled Tests warnings
t/lib/warnings/9uninit Tests "Use of uninitialized" warnings
t/lib/warnings/av Tests for av.c for warnings.t
t/lib/warnings/doio Tests for doio.c for warnings.t
t/lib/warnings/doop Tests for doop.c for warnings.t
t/lib/warnings/gv Tests for gv.c for warnings.t
t/lib/warnings/hv Tests for hv.c for warnings.t
t/lib/warnings/malloc Tests for malloc.c for warnings.t
Expand Down
5 changes: 1 addition & 4 deletions doop.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,7 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
}
else {
Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
"Use of strings with code points over 0xFF as"
" arguments to vec is deprecated. This will"
" be a fatal error in Perl 5.32");
Perl_croak(aTHX_ "Use of strings with code points over 0xFF as arguments to vec is forbidden");
}
}

Expand Down
2 changes: 1 addition & 1 deletion pod/perldeprecation.pod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This usage has been deprecated, and will no longer be allowed in Perl 5.32.

C<vec> views its string argument as a sequence of bits. A string
containing a code point over 0xFF is nonsensical. This usage is
deprecated in Perl 5.28, and will be removed in Perl 5.32.
deprecated in Perl 5.28, and was removed in Perl 5.32.

=head3 Use of code points over 0xFF in string bitwise operators

Expand Down
7 changes: 3 additions & 4 deletions pod/perldiag.pod
Original file line number Diff line number Diff line change
Expand Up @@ -7747,13 +7747,12 @@ operators treat their operands as strings of bytes, and values beyond

This became fatal in Perl 5.28.

=item Use of strings with code points over 0xFF as arguments to C<vec>
is deprecated. This will be a fatal error in Perl 5.32
=item Use of strings with code points over 0xFF as arguments to vec is forbidden

(D deprecated) You tried to use L<C<vec>|perlfunc/vec EXPR,OFFSET,BITS>
(F) You tried to use L<C<vec>|perlfunc/vec EXPR,OFFSET,BITS>
on a string containing a code point over 0xFF, which is nonsensical here.

Such usage will be a fatal error in Perl 5.32.
This became fatal in Perl 5.32.

=item Use of tainted arguments in %s is deprecated

Expand Down
6 changes: 2 additions & 4 deletions pod/perlfunc.pod
Original file line number Diff line number Diff line change
Expand Up @@ -9788,10 +9788,8 @@ to try to write off the beginning of the string (i.e., negative OFFSET).
If the string happens to be encoded as UTF-8 internally (and thus has
the UTF8 flag set), L<C<vec>|/vec EXPR,OFFSET,BITS> tries to convert it
to use a one-byte-per-character internal representation. However, if the
string contains characters with values of 256 or higher, that conversion
will fail, and a deprecation message will be raised. In that situation,
C<vec> will operate on the underlying buffer regardless, in its internal
UTF-8 representation. In Perl 5.32, this will be a fatal error.
string contains characters with values of 256 or higher, a fatal error
will occur.

Strings created with L<C<vec>|/vec EXPR,OFFSET,BITS> can also be
manipulated with the logical
Expand Down
14 changes: 0 additions & 14 deletions t/lib/warnings/doop

This file was deleted.

25 changes: 16 additions & 9 deletions t/op/vec.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use Config;

plan(tests => 78);

my $exception_134139 = "Use of strings with code points over 0xFF as arguments to vec is forbidden";

is(vec($foo,0,1), 0);
is(length($foo), undef);
Expand Down Expand Up @@ -65,18 +66,14 @@ $x = substr $foo, 1;
is(vec($x, 0, 8), 255);
$@ = undef;
{
no warnings 'deprecated';
local $@;
eval { vec($foo, 1, 8) };
ok(! $@);
like($@, qr/$exception_134139/,
"Caught exception: code point over 0xFF used as argument to vec");
$@ = undef;
eval { vec($foo, 1, 8) = 13 };
ok(! $@);
if ($::IS_EBCDIC) {
is($foo, "\x8c\x0d\xff\x8a\x69");
}
else {
is($foo, "\xc4\x0d\xc3\xbf\xc3\xbe");
}
like($@, qr/$exception_134139/,
"Caught exception: code point over 0xFF used as argument to vec");
}
$foo = "\x{100}" . "\xff\xfe";
$x = substr $foo, 1;
Expand Down Expand Up @@ -244,3 +241,13 @@ like($@, qr/^Modification of a read-only value attempted /,
$v = eval { RT131083(1, vec($s, $off, 8)); };
like($@, qr/Out of memory!/, "RT131083 lval ~0");
}

{
# Adapting test formerly in t/lib/warnings/doop

local $@;
my $foo = "\x{100}" . "\xff\xfe";
eval { vec($foo, 1, 8) };
like($@, qr/$exception_134139/,
"RT 134139: Use of strings with code points over 0xFF as arguments to 'vec' is now forbidden");
}

0 comments on commit b75e4ca

Please sign in to comment.