From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.6 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 09F306362CC for ; Tue, 22 Dec 2015 01:02:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] hval: move PRE constant for wrapping UGC here Date: Tue, 22 Dec 2015 01:02:14 +0000 Message-Id: <20151222010216.6684-3-e@80x24.org> In-Reply-To: <20151222010216.6684-1-e@80x24.org> References: <20151222010216.6684-1-e@80x24.org> List-Id: User-generated content (UGC) may have excessively long lines which screw up rendering. This is the only bit of CSS we use. --- lib/PublicInbox/Feed.pm | 4 ++-- lib/PublicInbox/Hval.pm | 5 +++++ lib/PublicInbox/SearchView.pm | 2 +- lib/PublicInbox/View.pm | 16 ++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 1201dd1..68f1e67 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -134,9 +134,9 @@ sub emit_html_index { qq{ } . qq{} . qq{} . - PublicInbox::View::PRE_WRAP; + PublicInbox::Hval::PRE; } else { - $top = PublicInbox::View::PRE_WRAP . $top . "\n"; + $top = PublicInbox::Hval::PRE . $top . "\n"; } $fh->write("$title" . diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index ab6e044..e0b85c6 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -10,6 +10,11 @@ use Encode qw(find_encoding); use URI::Escape qw(uri_escape_utf8); use PublicInbox::MID qw/mid_clean/; +# for user-generated content (UGC) which may have excessively long lines +# and screw up rendering on some browsers. This is the only CSS style +# feature we use. +use constant PRE => ""; + my $enc_ascii = find_encoding('us-ascii'); sub new { diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 7f79090..ea8a45a 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -31,7 +31,7 @@ sub sres_top_html { $total = $mset->get_matches_estimated; }; my $err = $@; - my $res = html_start($q, $ctx) . PublicInbox::View::PRE_WRAP; + my $res = html_start($q, $ctx) . PublicInbox::Hval::PRE; if ($err) { $code = 400; $res .= err_txt($err) . "
" . foot($ctx);
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 3c4e954..68741c5 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -21,7 +21,6 @@ require POSIX;
 # TODO: make these constants tunable
 use constant MAX_INLINE_QUOTED => 12; # half an 80x24 terminal
 use constant MAX_TRUNC_LEN => 72;
-use constant PRE_WRAP => "";
 use constant T_ANCHOR => '#u';
 use constant INDENT => '  ';
 
@@ -39,7 +38,7 @@ sub msg_html {
 	}
 	headers_to_html_header($mime, $full_pfx, $ctx) .
 		multipart_text_as_html($mime, $full_pfx) .
-		'

' . PRE_WRAP . + '
' . PublicInbox::Hval::PRE . html_footer($mime, 1, $full_pfx, $ctx) . $footer . ''; @@ -48,7 +47,8 @@ sub msg_html { sub feed_entry { my ($class, $mime, $full_pfx) = @_; - PRE_WRAP . multipart_text_as_html($mime, $full_pfx) . ''; + PublicInbox::Hval::PRE . + multipart_text_as_html($mime, $full_pfx) . ''; } sub in_reply_to { @@ -107,7 +107,7 @@ sub index_entry { if ($level) { $rv .= '
' . (INDENT x $level) . '
'; } - $rv .= "" . PRE_WRAP; + $rv .= "" . PublicInbox::Hval::PRE; $rv .= "$subj\n"; $rv .= "- $from @ $ts UTC - "; $rv .= "next"; @@ -206,8 +206,8 @@ sub emit_thread_html { $next .= "\ndownload thread: "; $next .= "mbox.gz"; $next .= " / follow: Atom feed"; - $cb->write("
" . PRE_WRAP . $next . "\n\n". $foot . - ""); + $cb->write("
" . PublicInbox::Hval::PRE . $next . "\n\n". + $foot . ""); $cb->close; } @@ -457,7 +457,7 @@ sub headers_to_html_header { $rv .= "\n"; ("". join(' - ', @title) . - "$atom" . PRE_WRAP . $rv); + "$atom" . PublicInbox::Hval::PRE . $rv); } sub thread_inline { @@ -634,7 +634,7 @@ sub ghost_table { my ($upfx, $mid, $level) = @_; "" . (INDENT x $level) . "" . - PRE_WRAP . ghost_parent($upfx, $mid) . + PublicInbox::Hval::PRE . ghost_parent($upfx, $mid) . ''; } -- EW