]> git.ipfire.org Git - thirdparty/public-inbox.git/commit
view: fix addr2url mapping corruption
authorEric Wong <e@80x24.org>
Fri, 6 Sep 2024 23:29:03 +0000 (23:29 +0000)
committerEric Wong <e@80x24.org>
Sat, 7 Sep 2024 00:06:59 +0000 (00:06 +0000)
commit3b51fcc196e357f61323bc9e17700b8e33fa08bc
tree3125c868268675189cad0823ae8ccafa271eb528
parent8ccd2719a74ae8c8937addc7881e3ed7e9aefd7b
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