Skip to content

Commit

Permalink
Linear: use BlockKit to avoid formatting injection
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Jul 4, 2024
1 parent 0d1086f commit aafd26b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/Synergy/Reactor/Linear.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use Future::AsyncAwait;
use Linear::Client;
use Lingua::EN::Inflect qw(PL_N);
use POSIX qw(ceil);
use Slack::BlockKit::Sugar -all => { -prefix => 'bk_' };
use Synergy::CommandPost;
use Synergy::Logger '$Logger';
use Synergy::Util qw(bool_from_text reformat_help);
Expand Down Expand Up @@ -313,24 +314,28 @@ async sub _handle_search ($self, $event, $arg) {
return await $event->reply($zero);
}

my $text = q{};
my $slack = q{};
my $text = q{};
my @blocks = bk_richsection(bk_bold("$header"));

for my $node ($page->payload->{nodes}->@*) {
my $icon = $want_plain ? '' : $self->_icon_for_issue($node);
$text .= "$node->{identifier} $icon $node->{title}\n";
$slack .= sprintf "<%s|%s> $icon %s\n",
$node->{url},
$node->{identifier},
$node->{title};
push @blocks, bk_richsection(
bk_link($node->{url}, $node->{identifier}),
" $icon ",
$node->{title},
);
}

chomp $text;
chomp $slack;

return await $event->reply(
"$header:\n$text",
{ slack => "*$header:*\n$slack" },
{
slack => {
blocks => bk_blocks(bk_richblock(@blocks))->as_struct
},
}
);
};

Expand Down

0 comments on commit aafd26b

Please sign in to comment.