lib/PublicInbox/Search.pm | 4 +++- t/search.t | 11 +++++++++-- diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 76a270bca0c01e9c6121c530ff405594f04d6114..b3fd532d80db1461b6604a60e08dfe9deeeeb04e 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -330,8 +330,10 @@ my $tmp = join(' ', map {; if (s!\b(d|rt|dt):([[:print:]]+)\z!date_parse_prepare( $to_parse //= [], $1, $2)!sge) { $_; + } elsif (/\s/) { + s/(.*?)\b(\w+:)// ? qq{$1$2"$_"} : qq{"$_"}; } else { - /\s/ ? (s/\A(\w+:)// ? qq{$1"$_"} : qq{"$_}) : $_ + $_ } } @$argv); # git-rev-parse can handle any number of args up to system diff --git a/t/search.t b/t/search.t index 36a8fb3085584a2342248ed29e32ff0bd7eb84f8..bcfe91f5d468e91867116c640f4966f1e9b1667e 100644 --- a/t/search.t +++ b/t/search.t @@ -536,13 +536,20 @@ 'Subject search reaches inside message/rfc822'); }); SKIP: { + my ($s, $g) = ($ibx->search, $ibx->git); + my $q = $s->query_argv_to_string($g, ["quoted phrase"]); + is($q, q["quoted phrase"], 'quoted phrase'); + $q = $s->query_argv_to_string($g, ['s:pa ce']); + is($q, q[s:"pa ce"], 'space with prefix'); + $q = $s->query_argv_to_string($g, ["\(s:pa ce", "AND", "foo\)"]); + is($q, q[(s:"pa ce" AND foo)], 'space AND foo'); + local $ENV{TZ} = 'UTC'; my $now = strftime('%H:%M:%S', gmtime(time)); if ($now =~ /\A23:(?:59|60)/ || $now =~ /\A00:00:0[01]\z/) { skip 'too close to midnight, time is tricky', 6; } - my ($s, $g) = ($ibx->search, $ibx->git); - my $q = $s->query_argv_to_string($g, [qw(d:20101002 blah)]); + $q = $s->query_argv_to_string($g, [qw(d:20101002 blah)]); is($q, 'd:20101002..20101003 blah', 'YYYYMMDD expanded to range'); $q = $s->query_argv_to_string($g, [qw(d:2010-10-02)]); is($q, 'd:20101002..20101003', 'YYYY-MM-DD expanded to range');