From: Eric Wong <e@80x24.org>
To: Filip Hejsek <filip.hejsek@gmail.com>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
meta@public-inbox.org
Subject: Re: Occasional web view corruption (extra html escapes)
Date: Fri, 6 Sep 2024 23:29:03 +0000 [thread overview]
Message-ID: <20240906232903.M567140@dcvr> (raw)
In-Reply-To: <20240906224206.M417183@dcvr>
Eric Wong <e@80x24.org> wrote:
> Coderepos were hiding the bug from me.
coderepos + cindex, that is.
> So I think adding a guard to prevent using regexp from empty -by_addr
> is a first step; but additional checks + preload fixes should
> probably be needed...
This should fix the immediate issue on its own:
-----8<-----
Subject: [PATCH] view: fix addr2url mapping corruption
We must avoid generating a qr/\b()\b/ regexp which matches
every word boundary. This is caused by a particular set of
circumstances for WWW instances:
1. extindex must be in use
2. cindex must NOT be in use OR WWW->preload wasn't used
(custom .psgi or non-p-i-{httpd,netd} users)
3. first HTTP request hits /$EXTINDEX/$MSGID/
(where $EXTINDEX is typically `all')
On extindex-using instances without a cindex configured, the
first HTTP request hitting the extindex encounters an empty
{-by_addr} hash table. This empty {-by_addr} hash table causes
View->addr2urlmap() to return an all-matching regexp which
corrupts HTML when attempting address substitutions.
cindex-using instances avoid the problem by triggering
_fill_all() during PublicInbox::WWW->preload and ensuring
{-by_addr} of the PublicInbox::Config object is populated.
Thanks to Konstantin for the initial report and Filip for the
immensely helpful explanation of the problem.
Helped-by: Filip Hejsek <filip.hejsek@gmail.com>
Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20240903-brainy-lionfish-of-saturation-71ae1a@lemur/
Fixes: 48cbe0c3c8dc4d26 (www: linkify inbox addresses in To/Cc headers, 2024-01-09)
---
lib/PublicInbox/View.pm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index bc093a20..154e7537 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -203,8 +203,12 @@ sub addr2urlmap ($) {
my $tmp = $ctx->{www}->{pi_cfg}->{-addr2urlmap};
my @k = keys %$tmp; # random order
delete @$tmp{@k[0..3]} if scalar(@k) > 7;
- my $re = join('|', map { quotemeta } keys %addr2url);
- $tmp->{$key} = [ qr/\b($re)\b/i, \%addr2url ];
+ if (scalar keys %addr2url) {
+ my $re = join('|', map { quotemeta } keys %addr2url);
+ $tmp->{$key} = [ qr/\b($re)\b/i, \%addr2url ];
+ } else { # nothing? NUL should never match:
+ [ qr/(\0)/, { "\0" => './' } ];
+ }
};
@$ent;
}
next prev parent reply other threads:[~2024-09-06 23:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 17:52 Occasional web view corruption (extra html escapes) Konstantin Ryabitsev
2024-09-03 18:42 ` Eric Wong
2024-09-03 19:18 ` Konstantin Ryabitsev
2024-09-03 19:11 ` Eric Wong
2024-09-03 19:22 ` Konstantin Ryabitsev
2024-09-04 13:14 ` Eric Wong
2024-09-04 14:42 ` Konstantin Ryabitsev
2024-09-06 22:20 ` Filip Hejsek
2024-09-06 22:42 ` Eric Wong
2024-09-06 23:29 ` Eric Wong [this message]
2024-09-07 1:24 ` Konstantin Ryabitsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240906232903.M567140@dcvr \
--to=e@80x24.org \
--cc=filip.hejsek@gmail.com \
--cc=konstantin@linuxfoundation.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).