about summary refs log tree commit diff stats
path: root/src/bindings
Commit message (Collapse)AuthorAgeFilesLines
* sixel, stbi, sandbox: fix fstat sandbox violationbptato2024-09-041-0/+3
| | | | | | | Until recently, glibc used to implement it as fstatat. So don't trap for fstatat (and for consistency, fstat), but return EPERM. Just to be sure, rewrite sixel & stbi to never call fread.
* bindings: remove zlibbptato2024-09-041-79/+0
| | | | unused
* term: don't panic if termcap tgetent failsbptato2024-08-171-9/+10
| | | | | | | | If TERM is unrecognized by termcap, retry as dosansi. When that fails, just fall back to the non-termcap code path. (There is no reason to panic without termcap; it's just one of the several capability detection mechanisms we use.)
* Move JS wrapper into Monouchabptato2024-06-034-653/+0
| | | | Operation "modularize Chawan somewhat" part 3
* js: fix runtime cleanupbptato2024-06-031-0/+4
| | | | | | | | | | | | | | This is a minefield. Intuitively, you would think that just clearing the opaque and manually freeing registered object should be enough. Unfortunately, this is not true; we do not store whether we are actually holding a reference to registered JS objects, so this approach leads to double frees. Instead, we add a QJS callback that is called right after the final GC cleanup, but before the list_free assertion. This way, we can be sure that any object still in our registry is referenced by us, and can therefore unreference them safely.
* Fix GCC 14 compilationbptato2024-05-301-2/+4
| | | | | | | | TODO: find the exact flags we need instead of -fpermissive. See also: https://todo.sr.ht/~bptato/chawan/12 https://forum.nim-lang.org/t/11587
* luwrap: use separate context (+ various cleanups)bptato2024-05-101-1/+1
| | | | | | Use a LUContext to only load required CharRanges once per pager. Also, add kana & hangul vi word break categories for convenience.
* luwrap: replace Nim unicode maps with libunicodebptato2024-05-091-4/+19
| | | | | | | | | | | | | | | | | Instead of using the built-in (and outdated, and buggy) tables, we now use libunicode from QJS. This shaves some bytes off the executable, though far less than I had imagined it would. Also, a surprising effect of this change: because libunicode's tables aren't glitched out, kanji properly gets classified as alpha. I found this greatly annoying because `w' in Japanese text would now jump through whole sentences. As a band-aid solution I added an extra Han category, but I wish we had a more robust solution that could differentiate between *all* scripts. TODO: I suspect that separately loading the tables for every rune in breaksViWordCat is rather inefficient. Using some context object (at least per operation) would probably be beneficial.
* client: make quit() actually quit, misc fixesbptato2024-05-041-0/+2
| | | | | | | * unwind the QJS stack with an uncatchable exception when quit is called * clean up JS references in JSRuntime free even when the Nim counterparts are still alive * simplify some tests
* js: fix various leaks etc.bptato2024-05-031-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't actually free the main JS runtime, probably because you can't do this without first waiting for JS to unwind the stack. (This has the unfortunate effect that code now *can* run after quit(). TODO: find a fix for this.) This isn't a huge problem per se, we only have one of these and the OS can clean it up. However, it also disabled the JS_FreeRuntime leak check, which resulted in sieve-like behavior (manual refcounting is a pain). So now we choose the other tradeoff: quit no longer runs exitnow, but it waits for the event loop to run to the end and only then exits the browser. Then, before exit we free the JS context & runtime, and also all JS values allocated by config. Fixes: * fix `ad' flag not being set for just one siteconf/omnirule * fix various leaks (since leak check is enabled now) * use ptr UncheckedArray[JSValue] for QJS bindings that take an array * allow JSAtom in jsgetprop etc., also disallow int types other than uint32 * do not set a destructor for globals
* adapter: update code stylebptato2024-04-261-2/+1
|
* sandbox: seccomp support on Linuxbptato2024-04-181-0/+49
| | | | | | | | | | | | | | | | | 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-176-185/+224
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* sandbox: add OpenBSD pledge/unveil supportbptato2024-04-031-0/+6
| | | | | | | | | | | | 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.
* Add capsicum supportbptato2024-03-281-0/+6
| | | | | | | | | | | | | 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.
* libregexp: update LRE_FLAG_UTF16 namebptato2024-03-211-1/+1
| | | | upstream now calls it unicode
* quickjs: reduce diff with upstreambptato2024-03-021-10/+4
| | | | | | * the uint8array thing is probably from txiki.js, but we never used it * upstream now has JS_GetClassID, importing that instead... (so this commit won't build :/)
* libregexp: cast flags to the right sizebptato2024-02-181-1/+1
| | | | We have less than 8 flags, so the set's size is 1.
* regex: re-work compileSearchRegexbptato2024-02-171-7/+16
| | | | | | | I've gotten tired of not being able to search for forward slashes. Now it works like in vim, and you can also set default ignore case in the config.
* js: define toStringTag properlybptato2024-01-241-0/+1
|
* js: small improvementsbptato2024-01-171-1/+1
| | | | | * turn JSFuncGenerator into a ref object (it's faster this way) * remove strformat dependency
* js: use Nim allocatorbptato2024-01-081-16/+30
|
* Use std/* imports everywherebptato2024-01-071-1/+1
|
* Fix some casing issuesbptato2024-01-061-1/+1
|
* Compile with styleCheck:usagesbptato2023-12-284-9/+9
| | | | much better
* dom: use JS_EvalFunction; add module fetching stubsbptato2023-12-251-0/+1
| | | | (still no module support in buffer...)
* bindings/quickjs: cint -> csize_tbptato2023-12-231-1/+2
| | | | | | cint was incorrect :/ Makes me wonder if maybe we should just use futhark after all...
* ftp: fix unnecessary slashes being added to path; move bindings/curlbptato2023-12-151-425/+0
| | | | also in ftp: clean up resources before exit
* http: use CURLU for URLsbptato2023-12-131-0/+78
|
* Move http out of main binarybptato2023-12-131-0/+3
| | | | | | | | | | | | Now it is (technically) no longer mandatory to link to libcurl. Also, Chawan is at last completely protocol and network backend agnostic :) * Implement multipart requests in local CGI * Implement simultaneous download of CGI data * Add REQUEST_HEADERS env var with all headers * cssparser: add a missing check in consumeEscape
* pager, container: add text selection/copyingbptato2023-12-031-0/+2
| | | | | | | | | | * Add select & copy selection functionality to container * Fix bug in generateSwapOutput where output could be misplaced because of zero-width cells * Add fromJSPromise, call runJSJobs in every iteration of the headed event loop * "await" pager actions that output a promise * Change default view source keybinding to `\'
* Get rid of clang 16 workaroundbptato2023-12-022-5/+20
| | | | | * bindings/quickjs: importc and use correct pointer types * add constcharp module for when it is unavoidable
* js: get rid of getJSValuebptato2023-12-021-1/+2
| | | | just use an UncheckedArray in the binding
* js: simplify toJSP0bptato2023-11-301-2/+6
| | | | | | | * Expose js_create_from_ctor from QuickJS and directly use that (instead of badly recreating it) * Do not call defineUnforgeable twice (it is inevitably called in toJSP0, so jsctor does not need it)
* bindings: find termcap on FreeBSDbptato2023-11-211-2/+13
| | | | | pkg-config does not find termcap (or really, ncurses) here, so we have to find it ourselves.
* http: use Accept-Encodingbptato2023-11-171-0/+1
| | | | just ask libcurl to decode
* Add jspropnames, CSSStyleDeclaration stubbptato2023-10-251-1/+5
|
* Remove trailing spacesbptato2023-10-232-85/+85
|
* base64: reduce pointless re-coding using JSStringbptato2023-10-211-0/+11
| | | | | We now expose some functions from QuickJS to interact with JavaScript strings without re-encoding them into UTF-8.
* javascript: add TextEncoder, TextDecoderbptato2023-10-211-0/+11
|
* ftp, file: better dirlist, fix FTP path issuebptato2023-09-191-1/+1
| | | | | | | | | * Dirlist is now unified across ftp and file loaders. It's basically a copycat of w3m's FTP dirlist, because I like how it looks. * We now hack around the cURL FTP path problem by always prepending a slash to the path. This is probably closer aligned with expectations than the default behavior.
* dom: add document.all, misc fixesbptato2023-09-191-0/+1
| | | | | | | | * Fix an issue with Collection cache invalidation (we must invalidate collections of the parent node on insertion, so that it triggers a refresh). * Remove circular reference of document.document, now we use a function instead.
* loader: add FTP supportbptato2023-09-191-0/+8
| | | | | | | | | | | | works, sort of still needs some work: * better dirlist, ideally make it look like file dirlist (or make file look like ftp dirlist. well, anyway, they should look the same) * absolute paths? (for now you have to append an extra slash to the path beginning) * ssh keys for sftp? (actually I haven't even tested sftp yet...)
* bindings: fix JSInterruptHandler signaturebptato2023-09-151-1/+1
|
* Allow overriding libcurl namebptato2023-08-261-3/+9
| | | | for better compatibility with curl-impersonate
* javascript: misc. refactoringsbptato2023-08-241-1/+3
| | | | | | | | | | | | * Remove some unused properties from objects * Un-extern JSFunctionList * Remove js/javascript dependency from regex (the wrapper functions were rather pointless) * Remove setProperty (only toJS(Table) used it, but there we have to use defineProperty instead.) * Accordingly, use definePropertyCWE in toJS(Table) * Simplify fromJSTable (replace pointer arithmetic with UncheckedArray) * Reduce implicit `result' usage
* javascript: finish LegacyUnforgeable + misc fixesbptato2023-08-201-0/+11
| | | | | | | | Add jsuffget, jsuffunc for setting LegacyUnforgeable on functions. Misc fixes: * define LegacyUnforgeable properties for native object shims * replace some macros with templates
* javascript: update Events, misc fixes & additionsbptato2023-08-201-3/+15
| | | | | | | | | | | | | | Events: just implement the interfaces, no events are triggered yet. JS changes: * add LegacyUnforgeable * make consts enumerable * fix crash in isInstanceOf * fix destructor warnings * refactor registerType As a result, peakmem is now 1G+ on 1.6.14. It stays ~750M on 2.0.0. Hmm. Well, better upgrade to 2.0.0 I guess.
* Fixes & workarounds to compile on Nim 2.0.0bptato2023-08-012-1/+4
| | | | | | | | | | | | | | * Import punycode, as it has been removed from stdlib. * Fix some syntax errors * Apparently you can no longer compare distinct pointers with nil. Add explicit comparisons with typeof(nil) instead. * htmlparser: rename _ to other, as semantics of _ have changed. (Quite a shame, it looked better with _. Oh well.) * Explicitly specify mm:refc, as the browser OOMs with orc for some reason. Confirmed to compile & run on 2.0.0, 1.6.14, 1.6.12, 1.6.10 and 1.6.8. (<1.6.8 it's broken & wontfix.)
* Include libunicode header in bindingbptato2023-07-151-0/+5
|
bec1afd8'>e4409c40 ^
9a7862a6 ^
e4409c40 ^

d326f24d ^
55ebd12c ^

ab8b1f12 ^
55ebd12c ^





d326f24d ^
e38e34bf ^

ab8b1f12 ^

d3f9d547 ^
ab8b1f12 ^
e38e34bf ^

01876e39 ^











57bfc74f ^
d326f24d ^
57bfc74f ^
d326f24d ^

e4409c40 ^
01876e39 ^
e4409c40 ^
d326f24d ^
e4409c40 ^



c7bfda90 ^

e38e34bf ^
d326f24d ^
e4409c40 ^



a2e94617 ^

9a7862a6 ^
e4409c40 ^
04a31662 ^

01876e39 ^








ab8b1f12 ^
d326f24d ^
ab8b1f12 ^
e38e34bf ^
01876e39 ^









ab8b1f12 ^
01876e39 ^



ab8b1f12 ^
01876e39 ^
2d161b7d ^
01876e39 ^


a2e94617 ^
e38e34bf ^
c7bfda90 ^









2d161b7d ^



e38e34bf ^


d326f24d ^

01876e39 ^

d326f24d ^

01876e39 ^
8c68f693 ^
01876e39 ^
c7bfda90 ^

01876e39 ^












c7bfda90 ^


1fc1d8af ^
01876e39 ^





c7bfda90 ^







e38e34bf ^



57bfc74f ^
d326f24d ^
57bfc74f ^
e4409c40 ^



9a7862a6 ^
01876e39 ^
e4409c40 ^
9a7862a6 ^
01876e39 ^


d326f24d ^
9a7862a6 ^

01876e39 ^
57bfc74f ^

d326f24d ^
57bfc74f ^

e4409c40 ^
57bfc74f ^
e4409c40 ^
57bfc74f ^
d326f24d ^
57bfc74f ^
9a7862a6 ^
e4409c40 ^
57bfc74f ^
e4409c40 ^
57bfc74f ^
e4409c40 ^

57bfc74f ^
57bfc74f ^
d326f24d ^
57bfc74f ^
9a7862a6 ^
e4409c40 ^


9a7862a6 ^

d326f24d ^
9a7862a6 ^


d326f24d ^
9a7862a6 ^
57bfc74f ^
5b288495 ^
9a7862a6 ^



57bfc74f ^
d326f24d ^
57bfc74f ^
9a7862a6 ^

a2e94617 ^
e4409c40 ^


57bfc74f ^

d326f24d ^
01876e39 ^
57bfc74f ^
01876e39 ^









e4409c40 ^
9a7862a6 ^
e4409c40 ^
57bfc74f ^

d326f24d ^
57bfc74f ^
9a7862a6 ^

e4409c40 ^




57bfc74f ^

d326f24d ^
01876e39 ^
57bfc74f ^
01876e39 ^
9a7862a6 ^




d326f24d ^
9a7862a6 ^

d326f24d ^
01876e39 ^
9a7862a6 ^
01876e39 ^
9a7862a6 ^





d326f24d ^
01876e39 ^
9a7862a6 ^
01876e39 ^









e4409c40 ^


57bfc74f ^
e4409c40 ^
57bfc74f ^
e4409c40 ^
57bfc74f ^
e4409c40 ^


9a7862a6 ^







e4409c40 ^

57bfc74f ^
d326f24d ^
57bfc74f ^
55ebd12c ^
e4409c40 ^
55ebd12c ^
e4409c40 ^
d326f24d ^


55ebd12c ^
e4409c40 ^
d326f24d ^


55ebd12c ^
e4409c40 ^






b6d1143c ^
e4409c40 ^





57bfc74f ^
d326f24d ^
57bfc74f ^
55ebd12c ^
e4409c40 ^




57bfc74f ^
d326f24d ^
57bfc74f ^
55ebd12c ^
e4409c40 ^








57bfc74f ^


d326f24d ^
57bfc74f ^
d326f24d ^

57bfc74f ^
6d7ee048 ^


01876e39 ^







4bb52da7 ^

d1349dd6 ^
d326f24d ^


6d7ee048 ^
95586cc2 ^
6d7ee048 ^
57bfc74f ^
e4409c40 ^
57bfc74f ^
4bb52da7 ^

d326f24d ^
4bb52da7 ^
2cd8e80b ^
4bb52da7 ^










d326f24d ^
4bb52da7 ^
d326f24d ^
4bb52da7 ^








d326f24d ^
4bb52da7 ^


d326f24d ^
4bb52da7 ^




d326f24d ^
4bb52da7 ^

d326f24d ^
4bb52da7 ^

d326f24d ^
4bb52da7 ^


03413d1c ^
4bb52da7 ^

d326f24d ^

4bb52da7 ^


d326f24d ^
4bb52da7 ^







d1349dd6 ^
4bb52da7 ^


d326f24d ^
4bb52da7 ^
2cd8e80b ^
4bb52da7 ^
8c68f693 ^
4bb52da7 ^



d1349dd6 ^

4bb52da7 ^


d1349dd6 ^
d326f24d ^

4bb52da7 ^

d1349dd6 ^
90d33dc9 ^
d1349dd6 ^

4bb52da7 ^

d326f24d ^
d1349dd6 ^
d326f24d ^
4bb52da7 ^

d1349dd6 ^
4bb52da7 ^




d326f24d ^
4bb52da7 ^


0a919c29 ^
4bb52da7 ^




8c68f693 ^
d326f24d ^
4bb52da7 ^


d326f24d ^
4bb52da7 ^

d326f24d ^
4bb52da7 ^



d326f24d ^

4bb52da7 ^




d326f24d ^
4bb52da7 ^
d326f24d ^

4bb52da7 ^
d326f24d ^


4bb52da7 ^
d326f24d ^
4bb52da7 ^
0a919c29 ^
4bb52da7 ^



d326f24d ^

8c68f693 ^




4bb52da7 ^

8c68f693 ^
4bb52da7 ^















d326f24d ^
4bb52da7 ^
d326f24d ^
4bb52da7 ^
0a919c29 ^
4bb52da7 ^

8c68f693 ^
4bb52da7 ^


8c68f693 ^

93ed2386 ^


4bb52da7 ^




d326f24d ^
4bb52da7 ^
d326f24d ^
4bb52da7 ^


d1349dd6 ^
4bb52da7 ^
01876e39 ^
4bb52da7 ^

d326f24d ^
4bb52da7 ^







57bfc74f ^

d326f24d ^
57bfc74f ^
d326f24d ^

57bfc74f ^
95586cc2 ^
57bfc74f ^
e4409c40 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817