Skip to content

Commit

Permalink
Include some of the latest Display.pm changes from VWF
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Mar 13, 2024
1 parent eff7bf5 commit 596d42e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/Geo/Coder/Free/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ sub new {
}

if(!-d $config_dir) {
if($args{default_config_directory}) {
$config_dir = $args{default_config_directory};
if($args{config_directory}) {
$config_dir = $args{config_directory};
} elsif($args{logger}) {
while(my ($k, $v) = each %ENV) {
$args{logger}->debug("$k=$v");
Expand Down Expand Up @@ -170,7 +170,6 @@ sub new {
_logger => $args{logger},
_cachedir => $args{cachedir},
%args,
# _page => $info->param('page'),
};

if(my $lingua = $args{'lingua'}) {
Expand All @@ -192,7 +191,7 @@ sub new {
$sm = HTML::SocialMedia->new({ cache => $smcache, lingua => $args{lingua}, logger => $args{logger} });
}
$self->{'_social_media'}->{'facebook_share_button'} = $sm->as_string(facebook_share_button => 1);
$self->{'_social_media'}->{'google_plusone'} = $sm->as_string(google_plusone => 1);
# $self->{'_social_media'}->{'google_plusone'} = $sm->as_string(google_plusone => 1);

return bless $self, $class;
}
Expand Down Expand Up @@ -268,13 +267,15 @@ sub get_template_path {
return $filename;
}

sub set_cookie {
sub set_cookie
{
my $self = shift;
my %params = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;

foreach my $key(keys(%params)) {
$self->{_cookies}->{$key} = $params{$key};
}
return $self;
}

sub http {
Expand Down Expand Up @@ -320,7 +321,7 @@ sub http {

# https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
return $rc . "X-Frame-Options: SAMEORIGIN\nX-Content-Type-Options: nosniff\n\n";
return $rc . "X-Frame-Options: SAMEORIGIN\nX-Content-Type-Options: nosniff\nReferrer-Policy: strict-origin-when-cross-origin\n\n";
}

sub html {
Expand Down Expand Up @@ -431,7 +432,8 @@ sub as_string {
return $rc . $self->html($args);
}

sub _debug {
sub _debug
{
my $self = shift;

if($self->{_logger}) {
Expand All @@ -442,6 +444,7 @@ sub _debug {
$self->{_logger}->debug($params{'message'});
}
}
return $self;
}

sub obfuscate {
Expand All @@ -463,8 +466,8 @@ sub _append_browser_type {
if($self->{_logger}) {
$self->{_logger}->debug("_append_browser_type: directory = $directory");
}
my $rc;

my $rc;
if(-d $directory) {
if($self->{_info}->is_search_engine()) {
$rc = "$directory/search:$directory/robot:";
Expand All @@ -480,7 +483,6 @@ sub _append_browser_type {
}

return ''; # Don't return undef or else the caller may use an uninit variable

}

1;

0 comments on commit 596d42e

Please sign in to comment.