diff options
author | Eric Wong <e@80x24.org> | 2017-10-04 22:54:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-10-04 23:35:28 +0000 |
commit | ec24b4af88d7922e4bf9846e76b9455fb6a5bda4 (patch) | |
tree | 435c91ff81c59448db3fd4ee3c919985ab9d521e /lib/PublicInbox/Hval.pm | |
parent | 38c481a5438593cff686709493a70b8a6b3033d1 (diff) | |
download | public-inbox-ec24b4af88d7922e4bf9846e76b9455fb6a5bda4.tar.gz |
This is hopefully more sensical than "raw" files from resulting downloads.
Diffstat (limited to 'lib/PublicInbox/Hval.pm')
-rw-r--r-- | lib/PublicInbox/Hval.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index 8d36fc2b..00a923ea 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -9,7 +9,7 @@ use warnings; use Encode qw(find_encoding); use PublicInbox::MID qw/mid_clean mid_escape/; use base qw/Exporter/; -our @EXPORT_OK = qw/ascii_html obfuscate_addrs/; +our @EXPORT_OK = qw/ascii_html obfuscate_addrs to_filename/; # for user-generated content (UGC) which may have excessively long lines # and screw up rendering on some browsers. This is the only CSS style @@ -106,4 +106,14 @@ sub obfuscate_addrs ($$) { /sge; } +# like format_sanitized_subject in git.git pretty.c with '%f' format string +sub to_filename ($) { + my ($s, undef) = split(/\n/, $_[0]); + $s =~ s/[^A-Za-z0-9_\.]+/-/g; + $s =~ tr/././s; + $s =~ s/[\.\-]+\z//; + $s =~ s/\A[\.\-]+//; + $s +} + 1; |