about summary refs log tree commit diff stats
path: root/adapter
Commit message (Collapse)AuthorAgeFilesLines
* sixel: break out into a separate cgi scriptbptato2024-08-241-0/+202
| | | | | | | | This caches sixel output. Works best when the line height is a multiple of 6px, but should still be faster than the previous solution everywhere else too (simply by virtue of encoding separate images in parallel). Next step: actual color quantization
* urldec: merge into urlencbptato2024-08-112-22/+18
| | | | also, move the ln command to make all
* md2html: label headings with their levelbptato2024-08-111-1/+2
| | | | like sr.ht does
* loader: move back data URL handlingbptato2024-08-031-32/+0
| | | | | | | data URIs can get megabytes long; however, you can only stuff so many bytes into the envp. (This was thwarting my efforts to view pandoc- generated standalone HTML in Chawan.) So put `data:' back into the loader process.
* buffer, pager, config: add meta-refresh + misc fixesbptato2024-07-281-1/+1
| | | | | | | | | * buffer, pager, config: add meta-refresh value, which makes it possible to follow http-equiv=refresh META tags. * config: clean up redundant format mode parser * timeout: accept varargs for params to pass on to functions * pager: add "options" dict to JS gotoURL * twtstr: remove redundant startsWithNoCase
* jebp: fix NEON simd bugbptato2024-07-231-1/+1
| | | | | | SRCtype and DSTtype were mixed up. See https://todo.sr.ht/~bptato/chawan/14
* img: add webp decoder (jebp)bptato2024-07-203-0/+4852
| | | | | | | | | | It works fine AFAICT, just missing VP8 deblocking filters, so lossy WebP images don't look great. I have extended the API a bit to allow reading from stdin, not just paths. Otherwise, it's the same as matanui159/jebp. TODO: add loop filters
* stbi: fix incompatible function pointer typebptato2024-07-181-2/+2
| | | | clang complains about this
* img, makefile: remove png, update uninstall targetbptato2024-07-031-553/+0
|
* pager: PNGify kitty images, clear images on buffer switchbptato2024-07-021-2/+10
| | | | | | | | | | | Saves bandwidth; it's especially useful over SSH. Still not sure if this is the right solution, since it now needs two select cycles instead of one, and it does yet another copy of the image. (Unnecessarily, because stbi cannot stream its output, and stbiw cannot stream its input.) Also, to save memory, we now discard decoded images of buffers that are not being viewed.
* stbi: fix broken allocation in resizingbptato2024-06-291-1/+1
| | | | ;_;
* img, loader: add image resizing, misc fixesbptato2024-06-283-10/+2688
| | | | | | | | | | | | | | | * resize images with stb_image_resize * use tee for output handle redirection (redirectToFile blocks) * cache original image files * accept lseek in sandbox * misc stbi fixes For now, I just pulled in stb_image_resize v1. v2 is an extra 150K in size, not sure if it's worth the cost. (Either way, we can always switch later if needed, since the API is almost the same.) Next step: move sixel/kitty encoders to CGI, and cache their output in memory instead of the intermediate RGBA representation.
* stbi: allow x-unknownbptato2024-06-221-1/+1
|
* stbi: add encodersbptato2024-06-213-17/+1807
|
* img: use stb_image, drop zlib as dependencybptato2024-06-204-19/+8087
| | | | | | | Now we have decoders for gif, jpeg, bmp. Also, the in-house PNG decoder has been replaced in favor of the stbi implementation; this means we no longer depend on zlib, since stbi comes with a built in inflate implementation.
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-0/+544
| | | | | | | | | | | | | | | * multi-processed and sandboxed PNG decoding & encoding (through local CGI) * improved request body passing (including support for output id as response body) * simplified & faster blob()/text() - now every request starts suspended, and OngoingData.buf has been replaced with loader's buffering capability * image caching: we no longer pull bitmaps from the container after every single getLines call Next steps: replace our bespoke PNG decoder with something more usable, add other decoders, and make them stream.
* Move JS wrapper into Monouchabptato2024-06-031-6/+2
| | | | Operation "modularize Chawan somewhat" part 3
* js: improve jsregex interfacebptato2024-06-031-71/+63
| | | | | | | It's easier to just use nested seqs here. (This also fixes reverse-search highlighting the last capture group instead of the whole match.)
* md2html: include numbers in idsbptato2024-06-031-3/+3
|
* about: markdownify & update license.htmlbptato2024-05-281-6/+6
| | | | We have a markdown converter, so why not use it?
* http: allow multiple early hintsbptato2024-05-221-1/+1
|
* man: quote keyword & sectionbptato2024-05-221-5/+5
|
* gopher: simplifybptato2024-05-213-38/+35
| | | | | * update naming * do not send status code (it was always 200 anyway)
* js: refactorbptato2024-05-081-1/+1
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* config: add insecure-ssl-no-verify option to siteconfbptato2024-05-012-0/+5
| | | | | | | Equivalent to curl --insecure. Note: unfortunately this does not help if the server is using unsafe legacy renegotiation, you have to allow that in the OpenSSL config.
* adapter: update code stylebptato2024-04-269-91/+81
|
* ftp: support multiple arguments in ssh config Hostbptato2024-04-261-13/+31
|
* data: replace std/base64 with atobbptato2024-04-251-5/+5
| | | | | | | | | | std's version is known to be broken on versions we still support, and it makes no sense to use different decoders anyway. (This does introduce a bit of a dependency hell, because js/base64 depends on js/javascript which tries to bring in the entire QuickJS runtime. So we move that out into twtstr, and manually convert a Result[string, string] to DOMException in js/base64.)
* http: fix sandbox violation in readFromStdinbptato2024-04-191-3/+3
| | | | | | | | | glibc apparently calls fstat from fread, and we didn't allow it in seccomp. So: * allow fstat in the sandbox; no reason not to, and it seems too big of a footgun to assume we never call fread * use read(2) in http; no need for buffered i/o here
* ftp: fix quoting bugbptato2024-04-091-0/+1
|
* sandbox: add OpenBSD pledge/unveil supportbptato2024-04-031-1/+1
| | | | | | | | | | | | pledge is a bit more fine-grained than Capsicum's capability mode, so the buffer & http ("network") sandboxes are now split up into two parts. I applied the same hack as in FreeBSD for overriding the buffer selector kqueue, because a) I didn't want to request sysctl promise b) I'm not sure if it would even work and c) if it breaks on OpenBSD, then it's broken on FreeBSD too, so there's a greater chance of discovering the bug.
* md2html: add trailing double space to <br> conversionbptato2024-04-021-0/+2
|
* man: fix command path manpage linksbptato2024-03-311-5/+6
| | | | isCommand was completely broken
* ansi2html: error out on unrecognized switchesbptato2024-03-291-1/+2
|
* ansi2html: support passing titlesbptato2024-03-291-2/+30
| | | | | | | Use content type attributes so e.g. git.cgi can set the title even with a text/x-ansi content type. (This commit also fixes some bugs in content type attribute handling.)
* ansi2html: do not use posixstreambptato2024-03-291-12/+15
| | | | it's an unnecessary abstraction here
* http: suppress proxy connect headersbptato2024-03-292-0/+2
| | | | causes problems with header parsing
* http: fix broken early hint handlingbptato2024-03-281-1/+2
| | | | | | | | | | | The empty string comparison here was in fact pointless; in cw-out.c, libcurl only calls cwb (which is curlWriteHeader in this case) if blen is not 0, so the string will never be empty. (Instead, it is expected to be \r\n; I've added \n too since CGI can already parse headers like that.) Normally it still worked because we just passed through the line to cgi.nim. However, it choked horribly on HTTP/2 early hints.
* Add capsicum supportbptato2024-03-281-0/+2
| | | | | | | | | | | | | It's the sandboxing system of FreeBSD. Quite pleasant to work with. (Just trying to figure out the basics with this one before tackling the abomination that is seccomp.) Indeed, the only non-trivial part was getting newSelector to work with Capsicum. Long story short it doesn't, so we use an ugly pointer cast + assignment. But even that is stdlib's "fault", not Capsicum's. This also gets rid of that ugly SocketPath global.
* ansi2html: add newline after pre tagbptato2024-03-241-1/+1
| | | | | it doesn't change anything in the dom, but this way it's easier to compose with other commands
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-0/+1
| | | | | | | | This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.)
* libregexp: update LRE_FLAG_UTF16 namebptato2024-03-211-1/+1
| | | | upstream now calls it unicode
* ansi2html: add separate switch for "standalone"bptato2024-03-211-1/+7
| | | | | this way its output can be embedded into documents without a pointless DT declaration
* ftp: basic sftp supportbptato2024-03-214-36/+128
| | | | | | | it still sucks, but it is at least slightly more usable. this also fixes a bug in dirlist where sort would mess up item name association
* man: improve processBackspace underscore handlingbptato2024-03-191-2/+6
| | | | | | it is best to base our interpretation of ^H_ on the current formatting, because a) it works predictably well on man output and b) a formatting mismatch results in manRe malfunctioning
* man: better error handlingbptato2024-03-171-35/+89
| | | | | | The "redirect stderr to stdout" scheme broke with groff/man-db, as it was spitting out warnings during execution. So now we handle stderr and stdout separately.
* data: content type fixesbptato2024-03-151-7/+5
| | | | | | | * do not skip first 5 chars (this is legacy from when we used query strings) * allow practically anything but control chars (so we can use parameters)
* man: improve header/footer conversionbptato2024-03-151-4/+11
| | | | | | | * run processBackspace on the first line, because groff likes to print formatting there too * check man references like SAMEPAGE(1) with isCommand because it's commonly found in footers
* man: work around parameter insanitybptato2024-03-151-6/+18
| | | | | | | | | | | | | | | | | | | | | This is horrible. -s means completely different things on various systems. -l does not exist on various systems. Nothing is standardized, except that man should take at least one parameter and that -k should perform a search. (Seriously, that's all.) So what we do is: * add a separate env var for overriding apropos * for man:, never use -s to specify sections * for man-k:, fall back to man, EXCEPT on FreeBSD which does not have a working section specifier on man -k (neither -S nor MANSECT does anything) * for man-l:, just pass the path wholesale to man and hope it does something useful. Also, we now set MANCOLOR to 1 so FreeBSD man gives us formatting as well.
* man: misc improvementsbptato2024-03-141-59/+71
| | | | | | | * do not use query string for arguments * accept symlinks as man binaries * improve error message reporting * run all regexes on the original line