Skip to content

Commit f2f6f89

Browse files
authored
Merge pull request #93 from Koan-Bot/koan.atoomic/fix-search-sanitization-bypass
2 parents 452449e + 65a4ba2 commit f2f6f89

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/lib/GrepCpan/Grep.pm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,8 @@ sub do_search ( $self, %opts ) {
266266

267267
my $t0 = [Time::HiRes::gettimeofday];
268268

269-
my $gitdir = $self->git()->work_tree;
270-
271269
$search = _sanitize_search($search);
270+
$opts{search} = $search;
272271

273272
# Validate regex before running git grep — invalid PCRE would silently
274273
# return empty results, confusing users.
@@ -964,9 +963,11 @@ sub run_git_cmd_limit ( $self, %opts ) {
964963
last if ++$counter > $limit_bg_process;
965964
}
966965
$run->close;
967-
print {$to_cache}
968-
qq{\n}; # in case of the last line did not had a newline
969-
print {$to_cache} END_OF_FILE_MARKER() . qq{\n} if $cache_file;
966+
if ($cache_file) {
967+
print {$to_cache}
968+
qq{\n}; # in case of the last line did not had a newline
969+
print {$to_cache} END_OF_FILE_MARKER() . qq{\n};
970+
}
970971
print {$CW} END_OF_FILE_MARKER() . qq{\n} if $can_write_to_pipe;
971972
say "-- Request finished by kid: $counter lines - "
972973
. join( ' ', 'git', @$cmd );

0 commit comments

Comments
 (0)