Add back serialization

FossilOrigin-Name: 380c160f7c82dc100c2203f03e89844a06c6bf8df07ac58413be93be3ea7465d
This commit is contained in:
nekobit 2022-08-09 01:56:59 +00:00
parent 1a4175351a
commit 03e62a5e51
5 changed files with 19 additions and 7 deletions

View File

@ -40,7 +40,6 @@ all:
$(MAKE) $(TARGET)
install_deps:
cpan HTML::Escape
cpan Template::Toolkit
make_ctmpls: $(TMPLS_C)

View File

@ -9,6 +9,7 @@ our @EXPORT = qw( account content_statuses );
use template_helpers 'to_template';
use l10n 'lang';
use status 'generate_status';
use string_helpers qw( simple_escape emojify );
sub generate_account
{
@ -21,6 +22,8 @@ sub generate_account
relationship => $relationship,
content => $content,
acct => $acct,
escape => \&simple_escape,
emojify => \&emojify,
);
to_template(\%vars, \$data->{'account.tt'});

View File

@ -1,7 +1,7 @@
package status;
use strict;
use warnings;
use string_helpers qw( reltime_to_str greentextify emojify format_username localize_mentions );
use string_helpers qw( reltime_to_str greentextify emojify format_username localize_mentions simple_escape );
use icons qw( get_icon visibility_to_icon );
use attachments 'generate_attachment';
use postbox 'generate_postbox';
@ -29,7 +29,7 @@ sub generate_status
make_emoji => \&generate_emoji,
greentextify => \&greentextify,
emojify => \&emojify,
escape => undef,
escape => \&simple_escape,
fix_mentions => \&localize_mentions,
format_username => \&format_username,
make_postbox => \&generate_postbox,

View File

@ -3,7 +3,7 @@ use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw( reltime_to_str greentextify emojify format_username get_mentions_from_content localize_mentions );
our @EXPORT = qw( reltime_to_str greentextify emojify format_username get_mentions_from_content localize_mentions simple_escape );
my $re_mentions = '(?=<a .*?mention.*?)<a .*?href="https?:\/\/(.*?)\/(?:@|users\/|\/u)?(.*?)?".*?>';
@ -19,6 +19,16 @@ sub reltime_to_str
return int($since / (60 * 60 * 24 * 365)) . 'yr';
}
sub simple_escape
{
my $text = shift;
$text =~ s/&/&amp;/gs;
$text =~ s/</&lt;/gs;
$text =~ s/>/&gt;/gs;
$text =~ s/"/&quot;/gs;
$text;
}
sub greentextify
{
my $text = shift;
@ -48,7 +58,7 @@ sub format_username
my $account = shift;
#TODO ESCAPE DISPLAY NAME
emojify($account->{display_name}, $account->{emojis});
emojify(simple_escape($account->{display_name}), $account->{emojis});
}
sub localize_mentions

View File

@ -16,7 +16,7 @@
[% END %]
<div class="acct-info-data">
<span class="acct-displayname">[% acct.display_name %]</span>
<span class="acct-displayname">[% emojify(escape(acct.display_name), acct.emojis) %]</span>
<span class="acct-username">@[% acct.acct %]</span>
</div>
@ -57,7 +57,7 @@
[% IF acct.note %]
<div class="account-info">
<div class="account-note">[% acct.note %]</div>
<div class="account-note">[% emojify(acct.note, acct.emojis) %]</div>
</div>
[% END %]