Skip to content

Commit aafd26b

Browse files
committed
Linear: use BlockKit to avoid formatting injection
1 parent 0d1086f commit aafd26b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/Synergy/Reactor/Linear.pm

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use Future::AsyncAwait;
1818
use Linear::Client;
1919
use Lingua::EN::Inflect qw(PL_N);
2020
use POSIX qw(ceil);
21+
use Slack::BlockKit::Sugar -all => { -prefix => 'bk_' };
2122
use Synergy::CommandPost;
2223
use Synergy::Logger '$Logger';
2324
use Synergy::Util qw(bool_from_text reformat_help);
@@ -313,24 +314,28 @@ async sub _handle_search ($self, $event, $arg) {
313314
return await $event->reply($zero);
314315
}
315316

316-
my $text = q{};
317-
my $slack = q{};
317+
my $text = q{};
318+
my @blocks = bk_richsection(bk_bold("$header"));
318319

319320
for my $node ($page->payload->{nodes}->@*) {
320321
my $icon = $want_plain ? '' : $self->_icon_for_issue($node);
321322
$text .= "$node->{identifier} $icon $node->{title}\n";
322-
$slack .= sprintf "<%s|%s> $icon %s\n",
323-
$node->{url},
324-
$node->{identifier},
325-
$node->{title};
323+
push @blocks, bk_richsection(
324+
bk_link($node->{url}, $node->{identifier}),
325+
" $icon ",
326+
$node->{title},
327+
);
326328
}
327329

328330
chomp $text;
329-
chomp $slack;
330331

331332
return await $event->reply(
332333
"$header:\n$text",
333-
{ slack => "*$header:*\n$slack" },
334+
{
335+
slack => {
336+
blocks => bk_blocks(bk_richblock(@blocks))->as_struct
337+
},
338+
}
334339
);
335340
};
336341

0 commit comments

Comments
 (0)