Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #156 from srvsh/escape-left-brace
Browse files Browse the repository at this point in the history
Escape left braces in regexes to fix warnings
  • Loading branch information
zachthompson committed Oct 27, 2015
2 parents 42b939f + 52dda14 commit b2397b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/DDG/Meta/Information.pm
Expand Up @@ -313,10 +313,10 @@ This function returns the plugin's attribution information in a hash
my $value = shift @{$_};
my ( $a, $b ) = ref $value eq 'ARRAY' ? ( $value->[0], $value->[1] ) : ( $value, $value );
my ( $link, $val ) = @{$supported_types{$type}};
$link =~ s/{{a}}/$a/;
$link =~ s/{{b}}/$b/;
$val =~ s/{{a}}/$a/;
$val =~ s/{{b}}/$b/;
$link =~ s/\Q{{a}}/$a/;
$link =~ s/\Q{{b}}/$b/;
$val =~ s/\Q{{a}}/$a/;
$val =~ s/\Q{{b}}/$b/;
push @attribution_links, $link, $val;
}
return \@attribution_links;
Expand Down
10 changes: 5 additions & 5 deletions lib/DDG/Rewrite.pm
Expand Up @@ -9,17 +9,17 @@ sub BUILD {
my ( $self ) = @_;
my $to = $self->to;
my $callback = $self->has_callback ? $self->callback : "";
croak "Missing callback attribute for {{callback}} in to" if ($to =~ s/{{callback}}/$callback/g && !$self->has_callback);
croak "Missing callback attribute for {{callback}} in to" if ($to =~ s/\Q{{callback}}/$callback/g && !$self->has_callback);
# Make sure we replace "{{dollar}}"" with "{dollar}".
$to =~ s/{{dollar}}/\$\{dollar\}/g;
$to =~ s/\Q{{dollar}}/\$\{dollar\}/g;
my @missing_envs;
for ($to =~ m/{{ENV{(\w+)}}}/g) {
for ($to =~ m/\Q{{ENV{\E(\w+)}}}/g) {
if (defined $ENV{$_}) {
my $val = $ENV{$_};
$to =~ s/{{ENV{$_}}}/$val/g;
$to =~ s/\Q{{ENV{$_}}}/$val/g;
} else {
push @missing_envs, $_;
$to =~ s/{{ENV{$_}}}//g;
$to =~ s/\Q{{ENV{$_}}}//g;
}
}
$self->_missing_envs(\@missing_envs) if @missing_envs;
Expand Down

0 comments on commit b2397b6

Please sign in to comment.