about summary refs log tree commit diff stats
path: root/src/server
Commit message (Collapse)AuthorAgeFilesLines
* config: switch to camel casebptato2025-01-134-6/+6
| | | | | | We already need a camel -> kebab converter anyway. Unfortunately this also changes JS binding names, so it's a breaking change. Oh well.
* loader: remove obsolete todobptato2025-01-121-1/+0
|
* buffer, dynstream: fix clone race, recvmsg/sendmsg castbptato2025-01-121-4/+4
| | | | | | | The fds must be read before the other buffer resumes execution. Also, for some reason, CMSG_SPACE/CMSG_LEN are inconsistent in their size with controllen on BSDs...
* loader: refcount LoaderBuffer pagesbptato2025-01-111-24/+9
| | | | | | | | | | | | One less unsafe/error prone construct. Refcounting the page as seq is unfortunate, but still miles better than zero-filling a non-refcounted array. (Plus it works better for base64 decoding.) The len field is still necessary, because old runtime doesn't support setLenUninit. Oh well, it's one wasted word, not the end of the world. As for the chunks, it looks like the allocator still uses small ones for the seq, so we're good.
* loader: fix memory leak on x-saveoutput + various fd leaksbptato2025-01-112-2/+4
|
* loader: truncate existing files on downloadbptato2025-01-111-1/+1
|
* loader: fix loader buffer page size optimizationbptato2025-01-111-1/+5
| | | | | | The goal is to get "SmallChunk" pages from the allocator. I think I stole the idea from faststreams, but the overhead might be different with raw pointers...
* bufreader, bufwriter: send all fds in one messagebptato2025-01-113-72/+75
| | | | | | | | Moves sendfd/recvfd out of C, and fixes some of its flaws too. The main one is that now all file descriptors are sent together. Also, I've decided to remove the ServerSocket after all; it's easy to add it back if it's ever needed again.
* buffer, ua.css, dom: more select adjustmentsbptato2025-01-101-39/+18
| | | | | | | ok, now it works like in w3m. (mostly, barring CSS limitations...) we'll see how this works out Also adds/fixes some select and option DOM APIs.
* buffer: remove server socketbptato2025-01-094-115/+58
| | | | | | | | | | | Now we just pass through a socket created in pager. This removes the need for a socket directory, and strengthens the buffer sandbox slightly. I've kept the ServerSocket code, because I want to add some form of RPC and communication between separate instances in the future. However, I don't expect this to be handled outside the main process, so I've removed the Capsicum-specific connectat/bindat code.
* dynstream: remove safeClose, add moveFdbptato2025-01-092-6/+3
| | | | | | | | | | | | | | | | | | | safeClose was originally added to prevent this bug: let fd = doSomething() # allocates fd on 0, e.g. by opening a socket let ps = newPosixStream(fd) ... discard dup2(ps.fd, STDIN_FILENO) ps.sclose() # stdin is now closed, despite the opposite intention. With safeClose called on fds that could be stdin, the goal was that stdin/stdout/stderr would never be allocated as a different file, but it was still error-prone. Enter moveFd: ps.moveFd(STDIN_FILENO) If ps is already stdin, this does nothing. If not, it dup2's ps to stdin, closes ps.fd, and sets it to stdin.
* bufstream: allow 0-width packetsbptato2025-01-091-2/+0
|
* buffer: make iframes clickablebptato2025-01-091-1/+18
| | | | better than nothing
* buffer: fix crash on clonebptato2025-01-081-0/+2
| | | | welp. bufreader chokes on 0-sized packets...
* loader: use per-process control socketsbptato2025-01-084-369/+372
| | | | | | | | | | | | | | | | | | | | | | | | Previously, each message (load, resume, passFd, etc.) would open a new connection to loader's UNIX socket, and assumed the loader was dead when the loader did not respond (ECONNREFUSED). As it turns out, this model was hopelessly broken: POSIX does not specify when a UNIX socket can refuse connections, so while it happened to work on Linux (which just blocks if it can't accept right now), FreeBSD would randomly refuse connections whenever its listen queue was full. Instead, we now take a socketpair() from the loader in addClient, and pass on one half to the client (the other half stays in loader); this is the control stream, and all messages from the specific client are sent through it. If a message includes a new stream (e.g. lcLoad), then it sends a new socketpair through the control stream. Aside from not being completely broken (and being marginally more efficient), this arrangement has several other benefits: it removes the need for authentication, almost removes the need for sockdir (now only buffers use it), and will make it easier to add async message processing in the future.
* dom: add document.referrerbptato2025-01-061-2/+4
| | | | Only works if referer-from is enabled.
* buffer: force restyle on toggleImagesbptato2025-01-061-1/+1
| | | | In some cases, it works without restyle, but not always.
* loaderiface: fix race in poll registerbptato2025-01-062-9/+30
| | | | | | | handleRead can register through fetch, so this doesn't work out as nicely as in loader (where we control all register/unregister calls). So now we queue up register events first, and only process them after the "events" iterator exits.
* dom: radiogroup fixesbptato2025-01-041-5/+0
|
* buffer: fix regression in restyle on window resizebptato2025-01-041-2/+6
| | | | it has to clear old styles too
* Try to set close-on-exec, misc cleanupbptato2025-01-043-14/+13
| | | | | | | | | | FD_CLOEXEC should hopefully get rid of bugs where buffers outlived the main process because of some stray child process keeping the canary pipe alive. It's not perfect because of the runMailcapWriteFile/runMailcapReadFile double-forks. Ideally they should be replaced with an implementation that tracks temporary files in the main process.
* env, buffer: restyle on getComputedStylebptato2025-01-031-49/+58
| | | | | | style/layout invalidation is a mess :( Fixes acid3 test00
* script, buffer: add <, > around URLbptato2025-01-031-1/+1
| | | | this way, markURL works on stack traces
* buffer: percent decode anchor in gotoAnchorbptato2025-01-031-1/+1
| | | | so that unicode anchors work too
* loader: add proper HTTP auth handlingbptato2025-01-032-7/+66
| | | | | | | | | | | | | Until now, we just stuffed it into the URL, which was somewhat problematic. Mainstream browsers like to hide the username from the user, but I've decided to follow w3m: buffers do not receive auth info, but the pager itself displays the username. As for the origin: I wanted to use the regular origin, but that does not work with any custom URL. So instead of changing the regular origin function, I've added another.
* pager: history fixesbptato2025-01-011-0/+1
| | | | | | | | | * add failed buffers to history too * make buffer.history and siteconf history actually do something * prevent history in dump mode after retry too * disable history in test configs ref. https://todo.sr.ht/~bptato/chawan/39
* buffer: make video, audio clickablebptato2024-12-301-26/+51
| | | | | more intuitive than shoehorning it into "view image" (also makes it easier to apply the content type)
* cookie: add persistent cookies, misc refactoring/fixesbptato2024-12-293-2/+3
| | | | | | | | | | | | | Mostly compatible with other browsers/tools that follow the Netscape/curl format. Cookie jars are represented by prepending "jar@" to the host part, but *only* if the target jar is different than the domain. Hopefully, other software at least does not choke on this convention. (At least curl seems to simply ignore the entries.) Also, I've moved cookies.nim to config so that code for local files parsed at startup remains in one place.
* config: clean up redundant CHA_DIR, update CGI docsbptato2024-12-292-20/+15
| | | | | "No CGI dir configured" is no longer a common case, so it's OK to just return "CGI file not found".
* env: do not copy attrs, fix screen on clientbptato2024-12-281-15/+14
| | | | Now screen.width etc. works in the pager too.
* CHA_CONFIG_DIR -> CHA_DIRbptato2024-12-271-1/+1
| | | | | | | It isn't really limited to config. It just happens to be in XDG_CONFIG_HOME because XDG basedirs suck. (W3M_DIR works similarly.)
* dom: add focus()bptato2024-12-271-0/+1
| | | | Respects autofocus.
* buffer: add "app" scripting modebptato2024-12-261-12/+13
| | | | | | | | | | For APIs that cannot be implemented in a privacy-friendly manner. As a start, I've added accurate screen size queries; getComputedStyle, getBoundingClientRect, etc. should follow. (We have a harmless getComputedStyle already, but it's broken.) Probably, things like JS-based scroll belong in here too, but I'm not sure yet. (Perhaps autofocus should be reused instead?)
* env: reflect user agent header in userAgentbptato2024-12-261-1/+3
|
* Misc character display fixesbptato2024-12-221-1/+1
| | | | | | | | | | | | | | | | | | * fix luwrap comparison function * strip high unicode controls in term/pager * use wcwidth in dirlist2html * remove combining category from strwidth * remove unused "disallowed" field from lineedit My initial goal with switching to wcwidth in dirlist2html was just to get rid of the outdated combining map in charwidth_gen. Then I realized that layout will normalize those out anyway, so we don't actually have to deal with them anywhere. Also, I found a few bugs in the process; high unicode control chars not being stripped out was a particularly bad one, as it allows for pages to mess up the terminal output. (Easiest way to replicate: just open a random binary file without this patch.)
* box: InlineFragment -> InlineBoxbptato2024-12-201-7/+7
| | | | | | It was named "fragment" mainly because I added it back when there was still a separate InlineBox type and I needed another name. Now InlineBox is gone, and I'm tired of typing fragment.
* buffer: only set new buffer's target on clonebptato2024-12-201-2/+2
|
* dom: add inline SVG supportbptato2024-12-201-2/+10
|
* response: automatically resume before closebptato2024-12-191-1/+4
| | | | doing it manually is too error prone
* css: add :target pseudo classbptato2024-12-171-0/+7
|
* default(T) -> T.default, add some strict defsbptato2024-12-173-6/+6
|
* css: resolve units to px before layoutbptato2024-12-161-3/+5
| | | | Lets us skip a couple pointless multiplications/divisions during layout.
* chabookmark fixes & improvementsbptato2024-12-152-1/+4
| | | | | | | | * correct action on M-b * add external.bookmark option * move openFileExpand functionality into unquote * add menu items * update docs
* twtstr: reduce copying in atobbptato2024-12-121-3/+3
|
* buffer: skip a copybptato2024-12-091-3/+3
|
* response: simplify text()bptato2024-12-081-42/+7
| | | | | | | | | | | | | It gets copied once anyway, so just use a blob. I guess I could skip the copy with some effort, but the 4 lines implementation is too attractive :P This is still an improvement, as it doesn't needlessly zero-fill the buffer on realloc. (I've also removed the final realloc from blob, as it seemed quite pointless. Using Content-Length could help... except it doesn't, because it refers to the encoded length. Ugh.)
* loader: fix heisenbugbptato2024-12-051-1/+6
| | | | | | | | | | | | | | | | | | Unconditionally registering output handles on resume could result in a failed assertion on double-register. The bug would appear like: resume (register) -> handleRead -> pushBuffer -> currentBuffer is nil -> register again handleWrite had a very high likelihood of occurring between resume and handleRead, and that hid the bug by immediately unregistering the handle after resume. In fact, I haven't been able to reproduce the bug at all today, and only found it after poring over the source... Fix this by not registering output handles that are empty (except if the istream is already finished, in which case it will just be unregistered).
* mimetypes: refactor, use mime.types for inline image extensionsbptato2024-12-052-6/+16
| | | | | | | | | | | | * remove std/streams use from mime.types; mmap and parse directly * use mime.types for inline image extensions * add some jpeg file extensions Latter came up because I was trying to add a format locally and it wouldn't recognize it on images from my file system (i.e. by extension). As a security measure we still do not allow additional extensions for predefined inline image types.
* dom: add support for @importbptato2024-12-011-6/+10
| | | | only the most basic form; no media queries yet
* buffer: fix nil derefbptato2024-11-301-1/+1
| | | | whoops