about summary refs log tree commit diff stats
path: root/src/loader
Commit message (Collapse)AuthorAgeFilesLines
* loader: fix crash on empty data URLsbptato2024-08-171-1/+8
|
* dom, xhr: slight progress on modules, fix an XHR bugbptato2024-08-151-0/+5
| | | | | | * actually download & compile modules (but don't run them yet) * fix a bug in XHR (on some older Nim versions, move() doesn't actually move)
* xhr: more progressbptato2024-08-152-7/+8
| | | | | | | | | | * add responseText, response * add net tests -> currently sync XHR only; should find a way to do async tests... * update monoucha -> simplified & updated some related code that no longer worked properly
* xhr: progressbptato2024-08-133-44/+90
| | | | | | | | | | | | | * fix header case sensitivity issues -> probably still wrong as it discards the original casing. better than nothing, anyway * fix fulfill on generic promises * support standard open() async parameter weirdness * refactor loader response body reading (so bodyRead is no longer mandatory) * actually read response body still missing: response body getters
* dom: fix crash on wrong image content typebptato2024-08-111-3/+2
| | | | + slightly optimize getContentType
* Update monouchabptato2024-08-093-90/+82
|
* loader: move back data URL handlingbptato2024-08-032-5/+50
| | | | | | | 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.
* Fixes for Nim 2.2bptato2024-07-294-6/+1
| | | | | | | | | * xmlhttprequest: fix missing import * painter: generic tuple workaround * dynstream: merge module with implementations (so it will work with vtables) Not enabling vtables yet since it doesn't work with refc.
* headers, request: bring it closer to the standardbptato2024-07-273-118/+215
| | | | | | * add standard interfaces to headers * use window base URL for newRequest * remove pointless generic in newRequest
* loader: follow redirects in fetch()bptato2024-07-271-4/+21
|
* loader: fix saveToBitmap for 0-len imagesbptato2024-07-271-1/+5
|
* loader: copy cached items on buffer cloningbptato2024-07-201-2/+11
| | | | | This fixes a bug where cloning buffers with images would crash the browser.
* loader: async status/headers for fetchbptato2024-07-192-23/+39
| | | | | | | | The status code & headers are no longer guaranteed to be sent right after res/outputId, so read them asynchronously instead. (This is pretty much the same code as the buffer connection handler in pager. Hopefully we can merge the two at some point.)
* html: event cleanup, XHR progressbptato2024-07-182-12/+62
|
* 32-bit compilation fixesbptato2024-07-131-5/+5
| | | | | | | | It seems registerHandle/unregister doesn't accept cint as handles. Not sure why it even works on 64-bit targets... (maybe some converter weirdness?) Seems best to explicitly cast it away.
* loader: fix fd leaksbptato2024-06-291-0/+2
|
* img, loader: add image resizing, misc fixesbptato2024-06-283-62/+66
| | | | | | | | | | | | | | | * 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.
* loader: fix failing assertionbptato2024-06-221-2/+4
| | | | | There is no guarantee that iclose is called exactly at rsBeforeStatus or rsBeforeHeaders.
* misc cleanupsbptato2024-06-221-1/+1
|
* client, pager: fix cached item refcounting bugsbptato2024-06-211-16/+36
|
* img, term: try to detect unknown images, improve kitty encoderbptato2024-06-211-2/+3
| | | | | | * preserve alpha in kitty + simplify encoder * pass unknown image types to stbi (as image/x-unknown) and let it detect the type
* img: use stb_image, drop zlib as dependencybptato2024-06-201-1/+1
| | | | | | | 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.
* loader: better error handlingbptato2024-06-203-20/+30
| | | | we no longer crash on broken codecs. yay
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-205-169/+258
| | | | | | | | | | | | | | | * 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.
* Update Chame, Chagashibptato2024-06-131-5/+1
|
* pager, buffer: improve forms, protocol configbptato2024-06-081-16/+0
| | | | | | * refactor form submission * add options to specify form handling per protocol * block cross-protocol POST requests
* Move JS wrapper into Monouchabptato2024-06-034-18/+21
| | | | Operation "modularize Chawan somewhat" part 3
* js: change jsstfunc syntaxbptato2024-06-031-1/+1
| | | | | | Interface:function -> Interface.function for consistency with regular JS syntax
* html: improve Request, derive Client from Windowbptato2024-05-204-148/+149
| | | | | | | * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same)
* config: separate tmp dir for sockets, usersbptato2024-05-161-1/+2
| | | | | | | * add $LOGNAME to the tmp directory name, so that tmpdirs of separate users don't conflict * use separate directory for sockets, so that we do not have to give buffers access to all cached pages
* buffer: fix multipart formsbptato2024-05-111-0/+1
| | | | | | | | | * fix enctype not getting picked up * fix form data constructor requiring open() syscall (which gets blocked by our seccomp filter) * add closing boundary to multipart end * pass fds instead of path names through WebFile/Blob and send those through bufwriter/bufreader
* js: refactorbptato2024-05-084-4/+4
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* loader: fix applying config for initial requestbptato2024-05-022-29/+45
| | | | | | Instead of the error-prone method of selectively applying config values only for non-initial requests, add a separate (privileged) loader command which allows specifying a different client config.
* config: add insecure-ssl-no-verify option to siteconfbptato2024-05-012-4/+10
| | | | | | | 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.
* url, twtstr: correct number parsingbptato2024-04-181-8/+5
| | | | | | | | | * do not use std's parse*Int; they accept weird stuff that we do not want to accept in any case * fix bug in parseHost where a parseIpv4 failure would result in an empty host * do not use isDigit, isAlphaAscii * improve parse*IntImpl error handling
* sandbox: seccomp support on Linuxbptato2024-04-181-5/+4
| | | | | | | | | | | | | | | | | We use libseccomp, which is now a semi-mandatory dependency on Linux. (You can still build without it, but only if you pass a scary long flag to make.) For this to work I had to disable getTimezoneOffset, which would otherwise call localtime_r which in turn reads in some files from /usr/share/zoneinfo. To allow this we would have to give unrestricted openat(2) access to buffer processes, which is unacceptable. (Giving websites access to the local timezone is a fingerprinting vector so if this ever gets fixed then it should be an opt-in config setting.) This patch also includes misc fixes to buffer cloning, and fixes the LIBEXECDIR override in the makefile so that it is actually useful.
* Update code stylebptato2024-04-175-17/+22
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* loader: constant time key comparisonbptato2024-04-021-1/+13
| | | | | GCC seems to generate something that strongly resembles a constant time comparison, so I guess this should be good enough.
* fflush() before forksbptato2024-03-281-0/+2
| | | | | seems like a good idea, especially because CGI uses stdout as the IPC mechanism
* Add capsicum supportbptato2024-03-281-2/+19
| | | | | | | | | | | | | 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.
* buffer: fix cancel()bptato2024-03-271-0/+1
| | | | | | | | | | * fix mismatch between return value & read value that would either crash or freeze the browser depending on its mood * add an assertion to detect the above footgun * fix some resource leaks * fix iteration over a table that called a function which altered the table in buffer's cancel() * if user cancels before anything is loaded, destroy the container too
* loader: fix failed doRequest handlingbptato2024-03-251-2/+1
| | | | copy-paste error
* js: proper distinction between Opt/Optionbptato2024-03-242-18/+17
| | | | | | | | | | | | | | | | until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
* cgi: reset SIGCHLD handler in childrenbptato2024-03-241-0/+4
| | | | this was causing problems in git.cgi
* io: derive DynStream from RootObj (not Stream)bptato2024-03-244-74/+76
| | | | | | | | 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.)
* io: add bufreaderbptato2024-03-211-122/+133
| | | | analogous to bufwriter
* config: add default-headers to siteconfbptato2024-03-212-14/+23
| | | | | | | So long as we have to live with siteconf, let's at least make it useful. Also, rewrite the header overriding logic because while it did work, it only did so accidentally.
* loader: set static CGI env vars in initLoaderContextbptato2024-03-212-7/+8
| | | | no reason to do it separately in setupEnv
* main: set CHA_LIBEXEC_DIR env var at startupbptato2024-03-192-10/+6
| | | | This way, we can use it everywhere (e.g. in mailcap).
* cgi: set cwd to CGI dirbptato2024-03-191-3/+7
| | | | | for w3m and real CGI compatibility; also, it makes more sense than using whatever directory the user happened to be in when starting the browser