]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
4 years agocheck for File::Temp 0.19 for ->newdir method
Eric Wong [Sun, 24 Nov 2019 03:12:37 +0000 (03:12 +0000)]
check for File::Temp 0.19 for ->newdir method

This is distributed with Perl 5.10.1 and onwards, so it should
not be an installation burden for any users.  I'm planning to
move away from tempdir() entirely and use File::Temp->newdir to
remove dependencies on END{} blocks.

4 years agot/xcpdb-reshard: use run_script for -xcpdb
Eric Wong [Fri, 15 Nov 2019 09:50:59 +0000 (09:50 +0000)]
t/xcpdb-reshard: use run_script for -xcpdb

This more than doubles the speed of the test, since we make
many invocations of -xcpdb.

4 years agot/indexlevels-mirror*: switch to run_script
Eric Wong [Fri, 15 Nov 2019 09:50:58 +0000 (09:50 +0000)]
t/indexlevels-mirror*: switch to run_script

This more than doubles the speed of these tests

4 years agot/v2mda: switch to run_script in many places
Eric Wong [Fri, 15 Nov 2019 09:50:57 +0000 (09:50 +0000)]
t/v2mda: switch to run_script in many places

This more than doubles the speed of the test.

4 years agot/watch_filter_rubylang: run_script for -init and -index
Eric Wong [Fri, 15 Nov 2019 09:50:56 +0000 (09:50 +0000)]
t/watch_filter_rubylang: run_script for -init and -index

This nets us a 20% speedup or so.

4 years agot/nntpd: use run_script for -init
Eric Wong [Fri, 15 Nov 2019 09:50:55 +0000 (09:50 +0000)]
t/nntpd: use run_script for -init

This only gives a 5% speedup or so, but anything helps.

4 years agot/watch_maildir_v2: use run_script for -init
Eric Wong [Fri, 15 Nov 2019 09:50:54 +0000 (09:50 +0000)]
t/watch_maildir_v2: use run_script for -init

This only gives a small 10% speedup or so, but anything helps.

4 years agot/httpd: use run_script for -init
Eric Wong [Fri, 15 Nov 2019 09:50:53 +0000 (09:50 +0000)]
t/httpd: use run_script for -init

This only gives a small ~10% speedup, since -httpd still
needs execve, but any speedup is welcome.

4 years agot/convert-compact: convert to run_script
Eric Wong [Fri, 15 Nov 2019 09:50:52 +0000 (09:50 +0000)]
t/convert-compact: convert to run_script

While this didn't use IPC::Run, having to reload several Perl
modules and scripts is slow and inefficient, so roughly
double the speed of this test.

4 years agot/v2mirror: switch to default run_mode for speedup
Eric Wong [Fri, 15 Nov 2019 09:50:51 +0000 (09:50 +0000)]
t/v2mirror: switch to default run_mode for speedup

We need to be careful and explicitly close FDs before doing
-index, since we can't rely on FD_CLOEXEC without execve(2)
syscalls.

4 years agodoc: remove IPC::Run as a dev and test dependency
Eric Wong [Fri, 15 Nov 2019 09:50:50 +0000 (09:50 +0000)]
doc: remove IPC::Run as a dev and test dependency

It's no longer needed and we're able to speed up some
of our tests as a result.

4 years agot/mda_filter_rubylang: drop IPC::Run dependency
Eric Wong [Fri, 15 Nov 2019 09:50:49 +0000 (09:50 +0000)]
t/mda_filter_rubylang: drop IPC::Run dependency

This test runs more than twice as fast, now.

4 years agot/mda: switch to run_script for testing
Eric Wong [Fri, 15 Nov 2019 09:50:48 +0000 (09:50 +0000)]
t/mda: switch to run_script for testing

Another noticeable speedup, this test is roughly ~3x faster now.

4 years agot/v2mirror: get rid of IPC::Run dependency
Eric Wong [Fri, 15 Nov 2019 09:50:47 +0000 (09:50 +0000)]
t/v2mirror: get rid of IPC::Run dependency

Not taking advantage of faster run modes in run_script, yet
since some lifetime problems need to be sorted.

4 years agot/purge: convert to run_script
Eric Wong [Fri, 15 Nov 2019 09:50:46 +0000 (09:50 +0000)]
t/purge: convert to run_script

This nets us another sizeable speedup.

4 years agot/init: convert to using run_script
Eric Wong [Fri, 15 Nov 2019 09:50:45 +0000 (09:50 +0000)]
t/init: convert to using run_script

This gives a 2-3x speedup on the test with the default
run_mode=1.

4 years agot/edit: switch to use run_script
Eric Wong [Fri, 15 Nov 2019 09:50:44 +0000 (09:50 +0000)]
t/edit: switch to use run_script

Perl parsing is slow, and run_script default behavior allows
this to speed up t/edit.t by over 100% in my case.

4 years agot/common: introduce run_script wrapper for t/cgi.t
Eric Wong [Fri, 15 Nov 2019 09:50:43 +0000 (09:50 +0000)]
t/common: introduce run_script wrapper for t/cgi.t

This will give us a consistent interface for running
test scripts in more performant ways while still giving
us a consistent interface to recreate real-world behavior
via spawn() (fork + execve), if needed.

The default run_mode (1) is faster and can run within the test
process with some minor adjustments to our code to avoid global
state.

This avoids the significante overhead of Perl code loading,
parsing and compilation phases.

4 years agospawn: which: allow embedded slash for relative path
Eric Wong [Fri, 15 Nov 2019 09:50:42 +0000 (09:50 +0000)]
spawn: which: allow embedded slash for relative path

This makes the subroutine behave more like which(1) command
and will make using spawn() in tests easier.

4 years agoxapcmd: do not fire END and DESTROY handlers in child
Eric Wong [Fri, 15 Nov 2019 09:50:41 +0000 (09:50 +0000)]
xapcmd: do not fire END and DESTROY handlers in child

We need to bypass whatever Test::More does with END/DESTROY
handlers for use in lon-lived process.  This doesn't affect
any of our normal code since we don't use END/DESTROY for
Xapcmd and its callers.

4 years agoimport: only pass Inbox object to SearchIdx->new
Eric Wong [Fri, 15 Nov 2019 09:50:40 +0000 (09:50 +0000)]
import: only pass Inbox object to SearchIdx->new

SearchIdx->new no longer accepts a GIT_DIR path as its argument
since commit 585314673236d664729fe3ab2d4fb229d1c0f2d5
("searchidx: require PublicInbox::Inbox (or InboxWritable) ref")

4 years agoinboxwritable: add ->cleanup method
Eric Wong [Fri, 15 Nov 2019 09:50:39 +0000 (09:50 +0000)]
inboxwritable: add ->cleanup method

We've been using this in -edit, and will be using it in some
more scripts and tests to optimize for run_mode=2 with
run_script.

Keeping this in the *Writable modules since I don't see it being
useful for the WWW and NNTP read-only interfaces which use
PublicInbox::Inbox.

4 years agolearn: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:38 +0000 (09:50 +0000)]
learn: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agomda: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:37 +0000 (09:50 +0000)]
mda: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agoinit: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:36 +0000 (09:50 +0000)]
init: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

We also need to rely on ->DESTROY instead of END{}
to unlink the lock file on sub exit.

4 years agoindex: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:35 +0000 (09:50 +0000)]
index: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agoadmin: get rid of singleton $CFG var
Eric Wong [Fri, 15 Nov 2019 09:50:34 +0000 (09:50 +0000)]
admin: get rid of singleton $CFG var

PublicInbox::Admin::config() just adds an extra layer of
indirection which we barely rely on.  So get rid of this
global variable and make it easier to run tests in the
future without relying on global state.

4 years agoedit: use OO API of File::Temp to shorten lifetime
Eric Wong [Fri, 15 Nov 2019 09:50:33 +0000 (09:50 +0000)]
edit: use OO API of File::Temp to shorten lifetime

Instead of relying on END{} blocks, rely on ->DESTROY
so the temporary files go out-of-scope and system
resources get released, sooner.

4 years agoedit: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:32 +0000 (09:50 +0000)]
edit: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agomboxgz: use Compress::Raw::Zlib instead of IO::Compress::Gzip
Eric Wong [Sat, 16 Nov 2019 02:34:39 +0000 (02:34 +0000)]
mboxgz: use Compress::Raw::Zlib instead of IO::Compress::Gzip

IO::Compress::Gzip is a wrapper around Compress::Raw::Zlib,
anyways, and being able to easily detach buffers to return them
via ->getline is nice.  This results in a 1-2% performance
improvement when fetching giant mboxes.

4 years agombox: split mboxgz out into a separate file
Eric Wong [Sat, 16 Nov 2019 02:34:38 +0000 (02:34 +0000)]
mbox: split mboxgz out into a separate file

It'll make using Compress::Raw::Zlib easier, since we
can use that and import constants more easily.

4 years agombox: unused mid_clean import
Eric Wong [Sat, 16 Nov 2019 02:34:37 +0000 (02:34 +0000)]
mbox: unused mid_clean import

We're gradually phasing mid_clean out (in favor of mids()).

4 years agodoc: check-man: save the result of successful runs
Eric Wong [Thu, 14 Nov 2019 06:41:14 +0000 (06:41 +0000)]
doc: check-man: save the result of successful runs

We can keep a stamp around if the corresponding manpage hasn't
changed to avoid re-running man(1) and awk(1).

4 years agot/psgi_mount: require SearchIdx before using
Eric Wong [Thu, 14 Nov 2019 06:41:13 +0000 (06:41 +0000)]
t/psgi_mount: require SearchIdx before using

We may not implicitly load it via other means in the future.

4 years agot/common: move unix_server to t/httpd-corner.t
Eric Wong [Thu, 14 Nov 2019 06:41:12 +0000 (06:41 +0000)]
t/common: move unix_server to t/httpd-corner.t

unix_server() is not commonly used, only t/httpd-corner.t uses
it and most HTTP tests use TCP since most HTTP libraries only
support TCP.

4 years agot/common: inline stream_to_string into t/feed.t
Eric Wong [Thu, 14 Nov 2019 06:41:11 +0000 (06:41 +0000)]
t/common: inline stream_to_string into t/feed.t

We only use it in one place and have favored test_psgi
in newer tests, so move it out-of-the-way to reduce startup
overhead of other *.t files.

4 years agodoc: mknews: support Email::MIME <1.930
Eric Wong [Thu, 14 Nov 2019 10:57:32 +0000 (10:57 +0000)]
doc: mknews: support Email::MIME <1.930

Email::MIME::header_str is not available until 1.930, so the
rest of our code uses Email::MIME::header for compatibility
with distros, since CentOS 7.x only has 1.926.

4 years agoconvert: remove duplicated GetOptions() call
Eric Wong [Thu, 14 Nov 2019 08:47:40 +0000 (08:47 +0000)]
convert: remove duplicated GetOptions() call

We only need to parse the command-line once.

4 years agoinboxwritable: drop {-importer} cyclic reference
Eric Wong [Thu, 14 Nov 2019 01:12:11 +0000 (01:12 +0000)]
inboxwritable: drop {-importer} cyclic reference

InboxWritable caching the result of ->importer leads to a
circular references with returned (V2Writable|Import) object
holds onto the calling InboxWritable object.

With public-inbox-watch, this leads to a memory leak if a user
is reloading via SIGHUP after a message is imported (it would
only become noticeable with SIGHUPs after every message imported).

I would not expect anybody to to notice this in real-world
usage.  I only noticed this since I was making -xcpdb suitable
for long-lived process use (e.g. "mod_perl style") and a flock
remained unreleased on v1 inboxes after resharding.

WatchMaildir (used by -watch) already handles caching of the
importer object itself, and all of our other real-world uses of
->importer are short-lived or designed for batch scripts, so
there's no need to cache the importer result internally.

4 years agoxapcmd: localize %SIG changes using "local"
Eric Wong [Wed, 13 Nov 2019 07:57:38 +0000 (07:57 +0000)]
xapcmd: localize %SIG changes using "local"

Perl's "local" allows changes to %SIG (and %ENV) to be limited
to its enclosing block.  This allows us to get rid of a global
variable and ad-hoc method for restoring signal handlers.

4 years agosolvergit: use --unidiff-zero with git-apply(1)
Eric Wong [Thu, 14 Nov 2019 01:03:38 +0000 (01:03 +0000)]
solvergit: use --unidiff-zero with git-apply(1)

I sometimes post context-free documentation patches generated
with "-U0" to reduce size and bandwidth overhead when replacing
URLs or updating copyright notices.  git-apply(1) needs the
--unidiff-zero switch to work properly with context-free
patches.

Given our search looks for blob OIDs, and we're never going
to be running the code we regenerate, "--unidiff-zero" ought
to be safe.

4 years agodoc: drop a repeated word
Kyle Meyer [Sat, 9 Nov 2019 00:38:06 +0000 (19:38 -0500)]
doc: drop a repeated word

4 years agot/*.t: disable nntpd/httpd worker processes in most tests
Eric Wong [Mon, 4 Nov 2019 03:01:37 +0000 (03:01 +0000)]
t/*.t: disable nntpd/httpd worker processes in most tests

And explicitly test for respawning in t/httpd-corner.t

There's no need to have an extra entries in the process table
for most tests we run, since that's not what we're testing.

4 years agot/hl_mod.t: remove IPC::Run (and File::Temp) dependency
Eric Wong [Mon, 4 Nov 2019 03:01:36 +0000 (03:01 +0000)]
t/hl_mod.t: remove IPC::Run (and File::Temp) dependency

We already load PublicInbox::Spawn for which(), so using spawn()
isn't unreasonable.  And rely on "skip" to log the omitted test
if w3m is missing, which means we need to update the "&&"
escaping test to be self-referential on the same line.

File::Temp was totally unused, there; and we can use "open ...,undef"
in Perl to easily create anonymous temporary files for use with
spawn().

4 years agot/httpd-corner.t: get rid of IPC::Run for running curl
Eric Wong [Mon, 4 Nov 2019 03:01:35 +0000 (03:01 +0000)]
t/httpd-corner.t: get rid of IPC::Run for running curl

We already load PublicInbox::Spawn, so there's no need to
add another dependency to make life difficult for potential
contributors.

4 years agot/httpd-corner.t: drop unnecessary bytes:: for length()
Eric Wong [Mon, 4 Nov 2019 03:01:34 +0000 (03:01 +0000)]
t/httpd-corner.t: drop unnecessary bytes:: for length()

We don't need to force byte semantics for a buffer we clearly
create (via ->read) with byte semantics.  Since we didn't
"use bytes" in t/httpd-corner.t, it was inadvertantly made
available by IPC::Run (which goes away, next).

4 years agot/*.t: remove IPC::Run dependency for git commands
Eric Wong [Mon, 4 Nov 2019 03:01:33 +0000 (03:01 +0000)]
t/*.t: remove IPC::Run dependency for git commands

One small step towards making tests easier-to-run.  We can rely
on "local $ENV{GIT_DIR}" for potentially shell-unsafe path
names, and the rest of our path names are relative and don't
contain characters which require escaping.

4 years agoedit: check for write errors writing "From_" line
Eric Wong [Fri, 8 Nov 2019 20:20:18 +0000 (20:20 +0000)]
edit: check for write errors writing "From_" line

We need to check every print to a regular file for errors,
because storage devices inevitably fail.

4 years agoedit: propagate correct editor exit code
Eric Wong [Fri, 8 Nov 2019 20:20:17 +0000 (20:20 +0000)]
edit: propagate correct editor exit code

exit($?) is never correct, since ($? >> 8) is needed to extract
the correct exit code, as other information (e.g. such as signal)
is encoded in $? in addition to the exit code.

4 years agodoc: actually document publicinboxwatch.watchspam
Eric Wong [Fri, 8 Nov 2019 06:09:02 +0000 (06:09 +0000)]
doc: actually document publicinboxwatch.watchspam

Instead of copy-pasting the documentation for `spamcheck'.

4 years agot/edit: use PublicInbox::Git::qx for pathname safety
Eric Wong [Mon, 4 Nov 2019 11:28:29 +0000 (11:28 +0000)]
t/edit: use PublicInbox::Git::qx for pathname safety

Another case where spaces can be in TMPDIR and cause
shell expansion with `command` to fail.

4 years agotests: rely on PublicInbox::Git for pathname safety
Eric Wong [Mon, 4 Nov 2019 11:13:47 +0000 (11:13 +0000)]
tests: rely on PublicInbox::Git for pathname safety

It's possible (but unlikely) a user will put spaces in TMPDIR
and cause File::Temp::tempdir() to return a temporary directory
with spaces in the filename, making it unsafe for shell
expansion.

PublicInbox::Git didn't exist when t/mda.t was written, and
I just forgot about PublicInbox::Git->qx for t/plack.t :x

4 years agot/httpd-corner.t: check for curl(1) errors in big async test
Eric Wong [Mon, 4 Nov 2019 02:27:23 +0000 (02:27 +0000)]
t/httpd-corner.t: check for curl(1) errors in big async test

curl(1) can fail and we need to invalidate the test in the
rare case it fails.

4 years agoindex: "git log" failures are fatal
Eric Wong [Mon, 4 Nov 2019 00:43:14 +0000 (00:43 +0000)]
index: "git log" failures are fatal

While I've never seen "git log" fail on its own, it could happen
one day and we should be prepared to abort indexing when it
happens.

Beef up tests for t/spawn.t to ensure close() behaves
on popen_rd the way we expect it to.

4 years agosearchidxshard: reuse $SIG{__WARN__} callback from Admin
Eric Wong [Sun, 3 Nov 2019 06:48:58 +0000 (06:48 +0000)]
searchidxshard: reuse $SIG{__WARN__} callback from Admin

We don't want to define $SIG{__WARN__} in the worker to call an
existing non-default callback.  Instead update ->{current_info}
the same way the V2Writable master process does.

I noticed this while reindexing with a large XAPIAN_FLUSH_THRESHOLD
and seeing the wrong epoch on my terminal from a shard because the
shard worker was spawned while reindexing a higher-numbered epoch.

4 years agopublic-inbox v1.2.0 v1.2.0
Eric Wong [Sun, 3 Nov 2019 03:01:40 +0000 (03:01 +0000)]
public-inbox v1.2.0

4 years agobuild: add "git-dist" target for making gzipped tarballs
Eric Wong [Sun, 3 Nov 2019 02:53:39 +0000 (02:53 +0000)]
build: add "git-dist" target for making gzipped tarballs

Since MANIFEST is tied to files tracked by git, adding generated
files such as NEWS to that is more effort than its worth (esp.
when I'm wondering if MakeMaker is useful compared to only using
GNU make).

I also have trouble reading CamelCase, so lower-case names
are nicer and more consistent with previous releases
(which were all generated with "git archive"); but did not
include NEWS.

4 years agodoc: mknews: force plain-text NEWS to UTF-8
Eric Wong [Sun, 3 Nov 2019 02:02:04 +0000 (02:02 +0000)]
doc: mknews: force plain-text NEWS to UTF-8

We'll have non-7-bit ASCII in the 1.2.0 release notes.

4 years agoTODO: update item for multiple Date: headers
Eric Wong [Sun, 3 Nov 2019 01:42:03 +0000 (01:42 +0000)]
TODO: update item for multiple Date: headers

That's the only head-scratcher of the bunch remaining, since
that relies on ranges.

4 years agodoc: add public-inbox.cgi(1) manpage
Eric Wong [Sat, 2 Nov 2019 21:51:08 +0000 (21:51 +0000)]
doc: add public-inbox.cgi(1) manpage

Yet another case of documenting things which should NOT be used :>

4 years agodoc: add public-inbox-purge(1) manpage
Eric Wong [Sat, 2 Nov 2019 21:34:59 +0000 (21:34 +0000)]
doc: add public-inbox-purge(1) manpage

Tools intended for end users need manpages, and doubly so
to convince potential users NOT to use them :)

4 years agohval: replace "&apos;" with "&#39;" for compatibility
Eric Wong [Thu, 31 Oct 2019 09:19:38 +0000 (09:19 +0000)]
hval: replace "&apos;" with "&#39;" for compatibility

While testing 216light.css changes, I managed to hit some cases
where dillo failed to render &apos; correctly, but I also can't
reproduce it reliably.  Anyways, it's definitely a problem with
some old browsers and newer versions of highlight already work
around it, but Debian 10.x has 3.41, so use "&#39;" to maximize
compatibility.

4 years agocontrib/css/216light: improve contrast a bit
Eric Wong [Thu, 31 Oct 2019 09:19:37 +0000 (09:19 +0000)]
contrib/css/216light: improve contrast a bit

"#ff0" foreground on a "#fff" background is just too difficult
to distinguish, among other things.  So choose slightly darker
colors when using a (painful) "#fff" background.

4 years agoqspawn: psgi_qx: delay callback until waitpid returns
Eric Wong [Thu, 31 Oct 2019 05:36:31 +0000 (05:36 +0000)]
qspawn: psgi_qx: delay callback until waitpid returns

We need to detect "git apply" failures reliably when patches
fail.  This is necessary for solving for blob 81c1164ae5 in
https://public-inbox.org/git/ when at least two messages can
solve for it (and one of them fails):

1. https://public-inbox.org/git/b9fb52b8-8168-6bf0-9a72-1e6c44a281a5@oracle.com/
2. https://public-inbox.org/git/56664222-6c29-09dc-ef78-7b380b113c4a@oracle.com/

4 years agosolvergit: deal with false-positive dfpost: results
Eric Wong [Thu, 31 Oct 2019 03:12:20 +0000 (03:12 +0000)]
solvergit: deal with false-positive dfpost: results

When solving for blob 81c1164ae5 in https://public-inbox.org/git/,
at least two messages get indexed with the dfpost result for
that blob (after fixing MsgIter to decode all text/* parts):

1. https://public-inbox.org/git/b9fb52b8-8168-6bf0-9a72-1e6c44a281a5@oracle.com/
2. https://public-inbox.org/git/56664222-6c29-09dc-ef78-7b380b113c4a@oracle.com/

However, only the first message contains a usable patch.  So
we must adjust SolverGit to account for multiple messages
hitting the same "dfpost:" search result and attempt
"git apply" on all results, not just the first.

In the future, changes to SearchIdx.pm may rid us of invalid
search results and speed up performance (at the expense of
developer/indexing time); but we need to account for old search
indices, first.

4 years agomsgiter: attempt to decode all text/* bodies
Eric Wong [Thu, 31 Oct 2019 03:12:19 +0000 (03:12 +0000)]
msgiter: attempt to decode all text/* bodies

We want to index text/x-patch and text/x-diff, at least,
since "git format-patch" can generate a patch series as
attachments using --attach.

4 years agomsgiter: do not assume UTF-8 if Email::MIME->body_str succeeds
Eric Wong [Thu, 31 Oct 2019 00:33:04 +0000 (00:33 +0000)]
msgiter: do not assume UTF-8 if Email::MIME->body_str succeeds

ISO-2202-JP and other non-UTF-8 messages need to be displayed
correctly.

Fixes: 7d82a8bc04ce ('handle "multipart/mixed" messages which are not multipart')
4 years agosearch: add note about SCHEMA_VERSION 15
Eric Wong [Wed, 30 Oct 2019 21:19:46 +0000 (21:19 +0000)]
search: add note about SCHEMA_VERSION 15

--reindex has gotten better over the years, and having parallel
Xapian DB directories would exceed all available disk space for
some users with giant inboxes.

4 years agowwwlisting: fix spelling and clarify sub location
Eric Wong [Wed, 30 Oct 2019 20:46:25 +0000 (20:46 +0000)]
wwwlisting: fix spelling and clarify sub location

Spell "Schwartzian" correctly, and clarify the location of
"modified" since we have multiple subs named "modified"

4 years agoMerge branch 'learn'
Eric Wong [Wed, 30 Oct 2019 20:46:44 +0000 (20:46 +0000)]
Merge branch 'learn'

* learn:
  doc: add public-inbox-learn(1) manpage
  mda: support multiple List-ID matches
  mda: prepare for multiple destinations
  inboxwritable: add assert_usable_dir sub
  mda: skip MIME parsing if spam
  mda: hoist out mda_filter_adjust
  filter/base: remove MAX_MID_SIZE constant
  mda: hoist out List-ID handling and reuse in -learn
  learn: hoist out remove_or_add subroutine
  learn: GIT_COMMITTER_<NAME|EMAIL> may be "" or "0"
  learn: update usage statement
  learn: only map recipient list on "ham" or "rm"
  learn: support multiple To/Cc headers

4 years agodoc: add public-inbox-learn(1) manpage
Eric Wong [Mon, 28 Oct 2019 10:45:28 +0000 (10:45 +0000)]
doc: add public-inbox-learn(1) manpage

Tools intended for end users need manpages.

4 years agomda: support multiple List-ID matches
Eric Wong [Mon, 28 Oct 2019 10:45:26 +0000 (10:45 +0000)]
mda: support multiple List-ID matches

While it's not RFC2919-conformant, mail software can
theoretically set multiple List-ID headers.  Deliver to all
inboxes which match a given List-ID since that's likely the
intended.

Cc: Eric W. Biederman <ebiederm@xmission.com>
Link: https://public-inbox.org/meta/87pniltscf.fsf@x220.int.ebiederm.org/
4 years agomda: prepare for multiple destinations
Eric Wong [Mon, 28 Oct 2019 10:45:25 +0000 (10:45 +0000)]
mda: prepare for multiple destinations

Multiple List-ID headers will be supported in the next commit

4 years agoinboxwritable: add assert_usable_dir sub
Eric Wong [Mon, 28 Oct 2019 10:45:24 +0000 (10:45 +0000)]
inboxwritable: add assert_usable_dir sub

And use it for mda, since "0" could be a usable directory
if somebody insists on using relative paths...

4 years agomda: skip MIME parsing if spam
Eric Wong [Mon, 28 Oct 2019 10:45:23 +0000 (10:45 +0000)]
mda: skip MIME parsing if spam

We don't want to waste cycles parsing the message for MIME bits
if it's spam.

4 years agomda: hoist out mda_filter_adjust
Eric Wong [Mon, 28 Oct 2019 10:45:22 +0000 (10:45 +0000)]
mda: hoist out mda_filter_adjust

It makes it easier to document the default -mda behavior is
stricter than normal, including "public-inbox-learn ham"

4 years agofilter/base: remove MAX_MID_SIZE constant
Eric Wong [Mon, 28 Oct 2019 10:45:21 +0000 (10:45 +0000)]
filter/base: remove MAX_MID_SIZE constant

We don't need it in the filter, here, since we have
one in the MDA package.

4 years agomda: hoist out List-ID handling and reuse in -learn
Eric Wong [Mon, 28 Oct 2019 10:45:20 +0000 (10:45 +0000)]
mda: hoist out List-ID handling and reuse in -learn

It's now possible to inject false-positive ham into an inbox
the same way -mda does via List-ID.

4 years agolearn: hoist out remove_or_add subroutine
Eric Wong [Mon, 28 Oct 2019 10:45:19 +0000 (10:45 +0000)]
learn: hoist out remove_or_add subroutine

We'll be reusing it for List-ID processing in the next commit.

4 years agolearn: GIT_COMMITTER_<NAME|EMAIL> may be "" or "0"
Eric Wong [Mon, 28 Oct 2019 10:45:18 +0000 (10:45 +0000)]
learn: GIT_COMMITTER_<NAME|EMAIL> may be "" or "0"

Users may be zeroes or blanks.

4 years agolearn: update usage statement
Eric Wong [Mon, 28 Oct 2019 10:45:17 +0000 (10:45 +0000)]
learn: update usage statement

Use <foo|bar> since that seems to be the favored notation
for required command args (taking a hint from git(1) manpage).
While we're at it, remove the space after '<' for the redirect
to match git.git coding style.

4 years agolearn: only map recipient list on "ham" or "rm"
Eric Wong [Mon, 28 Oct 2019 10:45:16 +0000 (10:45 +0000)]
learn: only map recipient list on "ham" or "rm"

It's assumed that "spam" can end up anywhere due to Bcc:, so we
need to scan every single inbox.  However, "rm" is usually more
targeted and and "ham" obviously only belongs in some inboxes.

4 years agolearn: support multiple To/Cc headers
Eric Wong [Mon, 28 Oct 2019 10:45:15 +0000 (10:45 +0000)]
learn: support multiple To/Cc headers

It's possible to specify these headers multiple times, and
PublicInbox::MDA->precheck takes that into account, so
-learn should, too.

4 years agoMerge remote-tracking branch 'origin/multi-mid'
Eric Wong [Wed, 30 Oct 2019 08:47:23 +0000 (08:47 +0000)]
Merge remote-tracking branch 'origin/multi-mid'

* origin/multi-mid:
  view: show X-Alt-Message-ID in permalink view, too
  index: allow search/lookups on X-Alt-Message-ID
  linkify: support adding "(raw)" link for Message-IDs
  view: improve warning for multiple Message-IDs
  view: move '<' and '>' outside <a>
  view: display redundant headers in permalink
  search: support multiple From/To/Cc/Subject headers

4 years agoHACKING: add a note about avoiding recursion
Eric Wong [Thu, 24 Oct 2019 21:09:42 +0000 (21:09 +0000)]
HACKING: add a note about avoiding recursion

Bad things happen when user data can control our stack size.

4 years agoview: show X-Alt-Message-ID in permalink view, too
Eric Wong [Thu, 24 Oct 2019 00:12:41 +0000 (00:12 +0000)]
view: show X-Alt-Message-ID in permalink view, too

Since we index X-Alt-Message-ID (because we need to placate some
NNTP clients), we now display it as well, since that Message-ID
could be the X-Alt-Message-ID that the reader is actually
interested in.

4 years agoindex: allow search/lookups on X-Alt-Message-ID
Eric Wong [Thu, 24 Oct 2019 00:12:40 +0000 (00:12 +0000)]
index: allow search/lookups on X-Alt-Message-ID

Since we replace extra Message-ID headers with X-Alt-Message-ID
to placate NNTP clients, we should allow searching and indexing
on X-Alt-Message-ID just like we do with Message-ID.

4 years agolinkify: support adding "(raw)" link for Message-IDs
Eric Wong [Thu, 24 Oct 2019 00:12:39 +0000 (00:12 +0000)]
linkify: support adding "(raw)" link for Message-IDs

And use it for the per-message permalink display.

4 years agoview: improve warning for multiple Message-IDs
Eric Wong [Thu, 24 Oct 2019 00:12:38 +0000 (00:12 +0000)]
view: improve warning for multiple Message-IDs

"refer" is not the correct term, here; since that would mean
multiple messages have the current message in the "References:"
header, and that's a normal occurence.

Instead, we need to warn the reader that the given message
itself has multiple Message-IDs.

4 years agoview: move '<' and '>' outside <a>
Eric Wong [Thu, 24 Oct 2019 00:12:37 +0000 (00:12 +0000)]
view: move '<' and '>' outside <a>

Browsers may underline '<' and '>' in links, which may be
confused with '≤' and '≥'.  So have the Message-ID header
display follow what we do with In-Reply-To headers and move the
"&lt;" and "&gt;" outside of <a> in the HTML.

4 years agoview: display redundant headers in permalink
Eric Wong [Thu, 24 Oct 2019 00:12:36 +0000 (00:12 +0000)]
view: display redundant headers in permalink

Mail headers can contain multiple headers of any type, so ensure
we don't hide any information we're getting in the per-message
permalink views.

This means it's possible to have multiple From, Date, To, Cc,
Subject, and In-Reply-To headers displayed.

The thread indices are a special case, I guess, since we run
out of space on the line if the headers too long and tools like
mutt only show the first one.

4 years agosearch: support multiple From/To/Cc/Subject headers
Eric Wong [Thu, 24 Oct 2019 00:12:35 +0000 (00:12 +0000)]
search: support multiple From/To/Cc/Subject headers

We can easily support searching on messages with
multiple From/To/Cc/Subject headers just like we
do with multiple Message-ID headers.

This matches the normal mutt pager display behavior.

4 years agoMerge branch 'regen'
Eric Wong [Tue, 22 Oct 2019 07:45:38 +0000 (07:45 +0000)]
Merge branch 'regen'

* regen:
  v2writable: use msgmap as multi_mid queue
  v2writable: move git->cleanup to the correct place
  v2writable: reindex handles 3-headered monsters
  v2writable: improve "num_for" API and disambiguate
  v2writable: set unindexed article number

4 years agodoc: clean-doc: remove generated standards.txt
Eric Wong [Tue, 22 Oct 2019 01:31:53 +0000 (01:31 +0000)]
doc: clean-doc: remove generated standards.txt

I need to remove all the generated documentation files
before running "git-set-file-times" for rsync to our
website.

4 years agosyscall: get rid of sendfile wrappers for now
Eric Wong [Mon, 21 Oct 2019 11:22:29 +0000 (11:22 +0000)]
syscall: get rid of sendfile wrappers for now

I'm not sure they'll make a measurable difference or will
be worth the effort in the future given the prevalance
of HTTPS and giant socket buffers.

Using Inline::C for this may make more sense in the
future, too, especially if we want to be able to use
GnuTLS.

4 years agohval: remove new_oneline
Eric Wong [Mon, 21 Oct 2019 11:22:28 +0000 (11:22 +0000)]
hval: remove new_oneline

commit 476fc666c223f0fb ('reduce "PublicInbox::Hval->new_oneline" use')
was mis-titled, since it completely eliminated ->new_oneline use.

4 years agogit: remove src_blob_url
Eric Wong [Mon, 21 Oct 2019 11:22:27 +0000 (11:22 +0000)]
git: remove src_blob_url

This was intended for solver, but it's unused since
commit 915cd090798069a4
("solver: switch patch application to use a callback")

4 years agowatchmaildir: remove redundant _path_to_mime
Eric Wong [Mon, 21 Oct 2019 11:22:26 +0000 (11:22 +0000)]
watchmaildir: remove redundant _path_to_mime

InboxWritable::maildir_path_load exists and we may support
it for use with standalone scripts.

4 years agoinboxwritable: import_maildir uses maildir_path_load
Eric Wong [Mon, 21 Oct 2019 11:22:25 +0000 (11:22 +0000)]
inboxwritable: import_maildir uses maildir_path_load

I'm not sure if this will get used anywhere, but at least
call a function which exists in dead code.

4 years agowww: remove unused ctx_get sub
Eric Wong [Mon, 21 Oct 2019 11:22:24 +0000 (11:22 +0000)]
www: remove unused ctx_get sub

This hasn't been used since commit 48b21cb662c1e17b7 in 2016:
("declare Inbox object for reusability")