Skip to content

Commit

Permalink
change how we redefine subroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed Dec 20, 2023
1 parent 168d3ba commit e573e89
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- change subroutine redefinition from INIT to BEGIN to avoid warnings (Tiago)

0.200
- refactor constants, stop use dualvars
- validate parameters on method check_publisher_restriction
Expand Down
51 changes: 26 additions & 25 deletions lib/GDPR/IAB/TCFv2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,6 @@ use constant {

use overload q<""> => \&tc_string;

INIT {
if ( my $native_decode_base64url = MIME::Base64->can("decode_base64url") )
{
no warnings q<redefine>;

*_decode_base64url = $native_decode_base64url;
}

eval {
require JSON;

if ( my $native_json_true = JSON->can("true") ) {
no warnings q<redefine>;

*_json_true = $native_json_true;
}

if ( my $native_json_false = JSON->can("false") ) {
no warnings q<redefine>;

*_json_false = $native_json_false;
}
};
}

# ABSTRACT: gdpr iab tcf v2 consent string parser

sub Parse {
Expand Down Expand Up @@ -647,6 +622,32 @@ sub looksLikeIsConsentVersion2 {
rindex( $gdpr_consent_string, CONSENT_STRING_TCF_V2->{PREFIX}, 0 ) == 0;
}

BEGIN {
if ( my $native_decode_base64url = MIME::Base64->can("decode_base64url") )
{
no warnings q<redefine>;

*_decode_base64url = $native_decode_base64url;
}

eval {
require JSON;

if ( my $native_json_true = JSON->can("true") ) {
no warnings q<redefine>;

*_json_true = $native_json_true;
}

if ( my $native_json_false = JSON->can("false") ) {
no warnings q<redefine>;

*_json_false = $native_json_false;
}
};
}


1;
__END__
Expand Down

0 comments on commit e573e89

Please sign in to comment.