Eric Wong [Sun, 17 Jan 2016 01:13:36 +0000 (01:13 +0000)]
repobrowse: italicize removed lines in diffs
This doesn't look too horrible on displays which render italics
and even degrades gracefully in text-only displays to underline
or colors in other terminals (lynx). Do not italicize leading
whitespace, since the fallback to underlines looks too noisy.
Eric Wong [Sun, 17 Jan 2016 00:32:24 +0000 (00:32 +0000)]
repobrowse: use 'raw' to link to the /plain/ endpoint
We use 'raw' in the rest of public-inbox to resolve the raw,
unformatted message (as does gmane and gitweb), so don't expose
the word 'plain' to users which only cgit seems to use.
Eric Wong [Sun, 17 Jan 2016 00:18:02 +0000 (00:18 +0000)]
repobrowse: allow serving PDF files from the 'plain' endpoint
PDFs are no more harmful than images or audio files
(they're not innocuous, but they're more difficult to use as an
XSS vector).
This prepares us to allow access the MIME_TYPE_WHITELIST for
serving random file types. But perhaps this will become
object-local to allow serving multiple, independent repobrowse
instances within one process...
Eric Wong [Sat, 16 Jan 2016 05:52:34 +0000 (05:52 +0000)]
rename PI_REPO_CONFIG => PI_REPOBROWSE_CONFIG
We want to use 'repobrowse' terminology consistently despite
it being longer. Furthermore, "repo-config" is an old git
command (nowadays git-config(1)) which may confuse some old
git users.
Eric Wong [Sat, 16 Jan 2016 03:21:06 +0000 (03:21 +0000)]
honor core.abbrev from git-config(1)
We will use core.abbrev=12 by default if unset, as the git
default of 7 is too low for long-term usability of links.
Some of our callers used 16, which was probably excessive.
Eric Wong [Sat, 16 Jan 2016 02:29:23 +0000 (02:29 +0000)]
repobrowse: eliminate oneline log view
The oneline view lacks sufficient information at times.
Reduce the number of options presented and always show
the full log message to avoid making the user follow more
links.
Eric Wong [Fri, 15 Jan 2016 22:04:30 +0000 (22:04 +0000)]
repobrowse: redirect w/o trailing slashes for humans
For human-visible HTML pages, avoid the trailing slash as that
can reduce cache hits in both the server (using varnish) and
clients. Typical web browsers are all capable of following
301 redirects without difficulty or human interaction.
We do not redirect for endpoints which may be consumed by
automated tools as that may cause compatibility problems. For
example, curl(1) does not automatically follow redirects and
needs the "-L" flag to do so.
Eric Wong [Thu, 14 Jan 2016 00:47:28 +0000 (00:47 +0000)]
repobrowse: queries are VCS-specific
While we want to keep a consistent set of parameters across
different VCSes, we cannot expect users of non-git VCSes to
use the same parameter names which make sense for git users.
Eric Wong [Sun, 3 Jan 2016 11:22:54 +0000 (11:22 +0000)]
repobrowse: tree view omits plain and log links
No need to clutter up the page with more senseless links few
people will follow. The blob view now has plain links for
people who want to save a single file, and will have log links
added, later.
Eric Wong [Sat, 26 Dec 2015 12:17:14 +0000 (12:17 +0000)]
repobrowse: support --graph output in log
This may be reverted if it turns out to be unsupportable
due to performance problems. However it certainly looks
useful for understanding commit history.
I'm keeping it off by default for now since taking over
500ms to render a page is not acceptable.
Even "git log --graph -50 554f6e41067b9e >/dev/null" on
git://git.kernel.org/pub/scm/git/git.git
takes around 700ms on my system.
Eric Wong [Thu, 24 Dec 2015 20:46:48 +0000 (20:46 +0000)]
repobrowse: patch generation improvements
It now works more or less correctly for merges (at least it does
what cgit does). It also supports path-limiting and the
signature line shows information on how the patch was generated
in an effort to educate git users.
Eric Wong [Thu, 24 Dec 2015 02:32:08 +0000 (02:32 +0000)]
repobrowse: blob view no longer displays line numbers
We will always support links to them, but they're a waste of
space and render poorly on small screens. Perhaps in the future
we may support linking to function context headers based on
.gitattributes, instead.
Eric Wong [Thu, 24 Dec 2015 01:56:22 +0000 (01:56 +0000)]
repobrowse: /commit/ forces everything to UTF-8
Hopefully we'll show some names properly in our pages now,
as well as simplify our code when escaping text for HTML
display.
Additionally, tweak our diff display by using <ins> and
<del> tags for added/removed text, respectively. This should
allow users to choose their own styles when viewing diffs
in their browser while being meaningful to people who cannot
differentiate colors.
Eric Wong [Wed, 23 Dec 2015 21:46:57 +0000 (21:46 +0000)]
repobrowse: git tree API modernizations
Rely on Hval more since that is stateful and hopefully makes it
easier-to-manage pathnames with weird characters. Additionally,
prefix individual function names to improve searchability
when/if we support additional VCSes.
Eric Wong [Wed, 23 Dec 2015 10:03:30 +0000 (10:03 +0000)]
examples/repobrowse.psgi: rename to eliminate the dash
We've been refering to this as "repobrowse", so drop the '-'.
While we're at it, enable chunking since we stream a good chunk
of our responses to avoid having too much in memory at once.
Eric Wong [Wed, 23 Dec 2015 10:00:20 +0000 (10:00 +0000)]
repobrowse: linkify hunk headers
A work-in-progress, but this provides useful links to the
exact line number of modified lines instead of blindly linking
to the top-of-the-file. Avoid flooding the user with links
but give hints by bolding the final resulting file or SHA-1
object ID.
Eric Wong [Tue, 5 Apr 2016 06:26:35 +0000 (06:26 +0000)]
view: link restructuring for index view
The "next/prev" links seem a bit awkward and I don't use them as
much as I expected to. However, move the "raw" message link
near the top since it's most useful for checking or reinforcing
the validity of the message via GPG or just reading headers.
Turn the Subject line into a permalink to the message, since
that's probably the common behavior anyways for other messaging
systems. Make the "[threaded|flat]" view links to always
visible for bookmark-ability despite the lack of a "permalink"
label.
Eric Wong [Mon, 4 Apr 2016 21:15:26 +0000 (21:15 +0000)]
http: fix condition for detecting persistence
Oops, we need to watch out for how we handle operator
precedence and ensure responses without a Content-Length
or "Transfer-Encoding: chunked" header will always
disconnect after writing.
Eric Wong [Thu, 17 Mar 2016 01:50:07 +0000 (01:50 +0000)]
daemon: expand @ARGV paths for running in '/'
We also require --stdout/--stderr/--pid-file to be absolute
paths for USR2 usage. However, allow PSGI files for -httpd
to be relative paths for ease-of-use.
Eric Wong [Sat, 12 Mar 2016 06:51:22 +0000 (06:51 +0000)]
searchmsg: preserve hard tabs, but drop CR (\r)
Hard tabs *may* be searchable, so preserve them since they do
not take up any more space than a normal space. However, CR
(carriage return) is worthless and likely a sign of a buggy mail
(or spam) client anyways.
Eric Wong [Sat, 12 Mar 2016 03:14:26 +0000 (03:14 +0000)]
examples: disable Chunked response in PSGI example
It seems incompatible with Starman and probably confuses other
HTTP/1.0-only servers, too. Our -httpd will respect it and
requires it for persistent connections.
Eric Wong [Sat, 12 Mar 2016 00:20:12 +0000 (00:20 +0000)]
http: prevent zero-byte writes
Plack::Middleware::Deflater (and perhaps other middleware)
triggers zero-byte writes which wastes syscalls when
they get passed to Danga::Socket. This may also trigger
problems when we introduce TLS support in the future.
Eric Wong [Fri, 11 Mar 2016 21:59:42 +0000 (21:59 +0000)]
daemon: fixup usage of the '-l' switch with IP/INET6 sockets
We need to ensure $sock_pkg is preserved outside of the loop.
The variable passed to "for" or "foreach" is implicitly local
and restores the previous value when the loop exits. This is
documented in the perlsyn manpage in the "Foreach Loops"
section.
Fixes: ea1b6cbd422b ("daemon: allow using IO::Socket::IP over INET6")
Eric Wong [Mon, 7 Mar 2016 17:43:19 +0000 (17:43 +0000)]
daemon: allow using IO::Socket::IP over INET6
IO::Socket::IP is bundled with newer versions of Perl,
so it is more likely to be available. There should
be no differences between these with our use cases.
Eric Wong [Sun, 6 Mar 2016 02:09:21 +0000 (02:09 +0000)]
http: ensure errors are printable before PSGI env
We cannot rely on a client socket having a PSGI env before headers
are fully-parsed as we seek to avoid storing hashes for idle
clients. Sso print errors to the psgi.errors value which belongs to
the httpd listener, instead.
Eric Wong [Sun, 6 Mar 2016 02:09:20 +0000 (02:09 +0000)]
http: reject excessive headers
HTTP::Parser::XS::PP does not reject excessively large
headers like the XS version. Ensure we reject headers
over 16K since public-inbox should never need such large
request headers.
Eric Wong [Sat, 5 Mar 2016 07:35:22 +0000 (07:35 +0000)]
t/httpd-corner: avoid clobbering existing FDs after fork
Due to the deterministic way reference counting works,
we do not want to drop references to existing FDs
even if we no longer need the glob reference; the actual
FD is all we can pass through on exec.
Eric Wong [Sat, 5 Mar 2016 05:44:16 +0000 (05:44 +0000)]
daemon: drop listener sockets ASAP on termination
We do not want to be accepting connections during graceful
shutdown because another new process is likely taking over.
This also allows us to free up the listener case another
(independent) process wants to claim it.
Eric Wong [Thu, 3 Mar 2016 10:33:02 +0000 (10:33 +0000)]
daemon: support listening on Unix domain sockets
Listening on Unix domain sockets can be convenient for running
behind reverse proxies, avoiding port conflicts, limiting access,
or avoiding the overhead (if any) of TCP over loopback.
Eric Wong [Thu, 3 Mar 2016 05:14:31 +0000 (05:14 +0000)]
daemon: introduce host_with_port for identifying sockets
This allows us to share more code between daemons and avoids
having to make additional syscalls for preparing REMOTE_HOST
and REMOTE_PORT in the PSGI env in -httpd.
This will also make supporting HTTP (and NNTP) over Unix sockets
easier in a future commit.
Eric Wong [Thu, 3 Mar 2016 05:14:30 +0000 (05:14 +0000)]
daemon: avoid polluting the main package
We've distilled the daemon code into one public function ("run"),
so avoid polluting the main namespace and just have users
prefix with the full package name for this rarely-used class.
Eric Wong [Thu, 3 Mar 2016 03:16:58 +0000 (03:16 +0000)]
use raw header for Message-ID
Message-IDs should not be MIME encoded, but in case they are,
use the raw form for compatibility with ssoma and possibly
other tools. This prevents a potential problem where a
malicious client could confuse our storage layer into indexing
incorrect contents.
Eric Wong [Tue, 1 Mar 2016 08:19:12 +0000 (08:19 +0000)]
http: better error handling for EMFILE/ENFILE
Better to throw the error back to the client ASAP if we're
out-of-descriptors. We will need to implement idle client
expiration for long-lived HTTP connections.
Eric Wong [Tue, 1 Mar 2016 03:44:04 +0000 (03:44 +0000)]
linkify: do not capture trailing '.' or ';' in URLs
It seems common for users to end statements with URLs,
while it is rare for a URL itself to end with a '.' or ';'.
So make a guess and assume the URL was intended to not
include the trailing '.' or ';'