Skip to content

Commit

Permalink
Merge pull request #9 from Perl-Toolchain-Gang/book/fix-version-strin…
Browse files Browse the repository at this point in the history
…g-comparisons

fix string comparisons with $] to use numeric comparison instead
  • Loading branch information
haarg authored Dec 17, 2024
2 parents fb58de1 + 606fea3 commit a4abea4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/HTTP/Tiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ sub _prepare_headers_and_cb {
}
elsif ( length $args->{content} ) {
my $content = $args->{content};
if ( $] ge '5.008' ) {
if ( "$]" >= 5.008 ) {
utf8::downgrade($content, 1)
or die(qq/Wide character in request message body\n/);
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ my $unsafe_char = qr/[^A-Za-z0-9\-\._~]/;
sub _uri_escape {
my ($self, $str) = @_;
return "" if !defined $str;
if ( $] ge '5.008' ) {
if ( "$]" >= 5.008 ) {
utf8::encode($str);
}
else {
Expand Down Expand Up @@ -1189,7 +1189,7 @@ sub write {
@_ == 2 || die(q/Usage: $handle->write(buf)/ . "\n");
my ($self, $buf) = @_;

if ( $] ge '5.008' ) {
if ( "$]" >= 5.008 ) {
utf8::downgrade($buf, 1)
or die(qq/Wide character in write()\n/);
}
Expand Down Expand Up @@ -1474,7 +1474,7 @@ sub write_content_body {
defined $data && length $data
or last;

if ( $] ge '5.008' ) {
if ( "$]" >= 5.008 ) {
utf8::downgrade($data, 1)
or die(qq/Wide character in write_content()\n/);
}
Expand Down Expand Up @@ -1521,7 +1521,7 @@ sub write_chunked_body {
defined $data && length $data
or last;

if ( $] ge '5.008' ) {
if ( "$]" >= 5.008 ) {
utf8::downgrade($data, 1)
or die(qq/Wide character in write_chunked_body()\n/);
}
Expand Down

0 comments on commit a4abea4

Please sign in to comment.