766 Commits

Author SHA1 Message Date
Tor Andersson
2385035568 Migrate to Codeberg. 2025-08-13 15:57:32 +02:00
Tor Andersson
05cd646bad Bug 708625: Use more common "stack" property for error stack trace. 1.3.7 2025-06-23 14:15:36 +02:00
Tor Andersson
f5b6492769 Issue #202: Special case for empty substring that splits surrogate pair.
The code to split non-BMP characters into surrogate pairs assumes that
we are actually splitting a character, and will fail when we ask it to
create a zero-length string in the middle of a surrogate pair split.

Special case zero-length substrings to work around this.
2025-06-16 15:48:52 +02:00
Tor Andersson
4bfb1a2575 Fix glitch with escape \x2d being treated as - in character classes.
Don't treat \x and \u escapes as "unquoted".
2025-05-05 15:34:05 +02:00
Tor Andersson
94ec2f2d7c Update character tables to include SpecialCasing.txt.
Use full mappings for String.prototype.to(Upper|Lower)Case, including
the mappings that change the string length (for example "ß" to "SS").
2025-02-10 12:12:13 +01:00
Tor Andersson
cc569c5fa9 Update character tables to Unicode 16. 1.3.6 2025-01-31 15:38:04 +01:00
Tor Andersson
aeb584ce40 Remove stale IRC link. 2025-01-27 00:10:11 +01:00
Tor Andersson
91abee5641 Issue 193 and issue 194: Always use heapsort instead of quicksort.
The quicksort implementation behaves badly when presented with
non-deterministic comparison functions.

The heapsort is more robust and has fewer edge cases to worry about
in the face of an adversarial comparison function.
2025-01-03 13:46:45 +01:00
Tor Andersson
02147f5a9f Simplify Array.prototype.sort by sorting in place without libc.
Don't use libc qsort (which uses malloc on gnu libc) which can leak
memory if the callback throws an exception.

Implement a simple quicksort (with insertion sort for small fragments).

Also included is a bottom-up heapsort implementation, which may be used
instead if built with -DJS_HEAPSORT=1 preprocessor define.
2024-11-26 21:26:12 +01:00
Tor Andersson
0df0707f2f Release 1.3.5. 1.3.5 2024-06-20 13:01:41 +02:00
Tor Andersson
40556b31c6 Issue #130: Fix bug with String.prototype.split(RegExp).
The "empty string at end of last match" should only trigger if the match
is empty!
2024-01-26 14:18:54 +01:00
Tor Andersson
d2697fd643 Expose extended unicode characters as surrogate pairs in String methods.
Split extended characters into surrogate pairs for charCodeAt, string
indexing, and the string slice/subset functions.

Escape surrogate code points in JSON stringify.
2024-01-26 14:18:54 +01:00
Tor Andersson
a442a0418f Issue #164: Use correct scope for function declaration bindings.
TODO: Make binding for function expression names immutable!
2024-01-22 14:22:01 +01:00
Tor Andersson
7e27931468 Increase default stack sizes. 2024-01-19 14:43:08 +01:00
Tor Andersson
e0885b354c regex: Dynamically allocate character class buffer.
Use a huge buffer for compilation, copy into exact size for program.

Merge overlapping and adjoining character class ranges.

This reduces the number of classes needed for badly constructed
character classes like [ABCDEFGHIJKLMNOPQRSTUVWXYZ].
2024-01-19 14:43:08 +01:00
Tor Andersson
a76d157bda Release 1.3.4. 1.3.4 2023-11-21 16:27:50 +01:00
Tor Andersson
9f5bc0ff81 Finalize user data if object allocation fails. 2023-08-10 17:13:37 +02:00
Tor Andersson
9bd3edcbcd Fix bug when cleaning up after allocation error. 2023-08-10 17:04:53 +02:00
Tor Andersson
ddd770933b Handle sign when converting integer strings to numbers. 2023-05-08 12:38:46 +02:00
Tor Andersson
db212180bf Allow disabling readline support in Makefile.
make HAVE_READLINE=no
2023-04-04 15:22:39 +02:00
Tor Andersson
57e3f01d5f Add install-static and install-shared targets. 1.3.3 2023-01-10 12:11:11 +01:00
Tor Andersson
f190f88ee2 Simplify Makefile. 2023-01-09 16:09:28 +01:00
Tor Andersson
bb6a85a31c Issue #171: Compile sparse array initializers correctly.
Don't initialize the holes with "undefined".
Elided array entries should be skipped altogether.
2023-01-09 14:44:02 +01:00
Tor Andersson
32f3e71169 Issue #171: Fix Object.keys implementation for flat arrays and strings.
Object.keys was not producing keys for the array part of a flat array.
It was also producing an array of numbers rather than strings for
string objects.
2023-01-05 15:48:28 +01:00
Tor Andersson
2e2738b293 Change js_Value to union to avoid some compiler optimization warnings.
Use a union of a union and the padding + type tag, to let the shrstr
object size be the full 16 bytes to avoid compiler complaints about
stepping out of bounds of the array when it optimizes heavily.
2023-01-05 15:32:41 +01:00
Tor Andersson
dd149b98bd Split debug printing of bytecode etc into "pp" tool. 2023-01-05 15:32:41 +01:00
Tor Andersson
d283465777 Regenerate Unicode data from latest UnicodeData.txt 2023-01-04 17:29:22 +01:00
Tor Andersson
278590fcb4 Merge the small private header files into jsi.h 2023-01-04 17:29:22 +01:00
Tor Andersson
71ffe07495 Fix longjmp warnings. 2023-01-04 17:29:22 +01:00
Tor Andersson
88b31f342d Allow holes at the end of a simple array.
Don't unflatten when creating with a = new Array(10).
Don't unflatten when deleting the last element.
2023-01-04 17:28:23 +01:00
Tor Andersson
7d9888b739 Return "undefined" from C functions if no return value is pushed.
Don't return the last input argument in this case.
2023-01-04 17:28:23 +01:00
Tor Andersson
bd037ab7aa Bug 706081: Fix off by one in size calculation. 2022-11-16 21:12:23 +01:00
Tor Andersson
09b3fcb1e7 Bug 706075: Fix errors in property deletion.
1) Copy "level" from the replacement node.
2) Fix rebalancing by using exact algorithm from AA-tree paper.
2022-11-14 17:43:58 +01:00
Tor Andersson
f882c6c5fe Rename private functions to avoid problems with MSYS stdio.h. 2022-11-09 16:01:43 +01:00
Tor Andersson
66d98a5f8e Fix Array.prototype.slice when deleteCount is missing.
Use behavior from newer JS specifications.
2022-11-07 16:25:09 +01:00
Tor Andersson
c067e1299c Avoid using the string interning table.
Make a copy of the property name in the same allocation as the property slot.
Make a copy of the internal string value of String objects.
2022-11-07 16:25:09 +01:00
Tor Andersson
0e611cdc0c 1.3.2 patch release for UAF bug fix. 1.3.2 2022-11-07 16:24:56 +01:00
Tor Andersson
edb50ad66f Bug 706057: Fix use-after-free in getOwnPropertyDescriptor.
getOwnPropertyDescriptor should create the descriptor object by
using [[DefineOwnProperty]], and not by looking through the prototype
chain where it may invoke getters and setters on the Object.prototype.

If there exists an Object.prototype.get property with a setter, that method is
invoked when it shouldn't. A malicious getter here can delete the property
currently being processed in getOwnPropertyDescriptor, and we'll end up
with a use-after-free bug.

Avoid this problem by following the spec and use js_defproperty rather than
js_setproperty to define own properties in getOwnPropertyDescriptor and
related functions.
2022-11-07 13:44:24 +01:00
Tor Andersson
bf4ac94207 Set length of output array Array.prototype.map. 2022-10-26 20:42:29 +02:00
Tor Andersson
69e2767d0a Make a patch release for important iterator bug fix. 1.3.1 2022-10-20 18:19:41 +02:00
Tor Andersson
8b5ba20957 Issue #166: Use special iterator for string and array indices.
Add a scratch buffer to js_State to hold temporary strings.
2022-10-20 18:14:54 +02:00
Ismael Luceno
d592c785c0 Enable choice of library version for shell
Default behavior is unchanged, but enables to chose the dynamic version by
passing "libmujs=libmujs.so" to make.
2022-10-17 14:53:27 +02:00
Ismael Luceno
1138515255 Use $(@D) instead of $(dir $@) 2022-10-17 14:53:27 +02:00
Ismael Luceno
4d3165baf5 Bug 705905: Compute VERSION using Make. 2022-10-17 14:52:13 +02:00
Tor Andersson
ebf235bfea Bump version number. 1.3.0 2022-10-11 18:18:55 +02:00
Sebastian Rasmussen
bbb2c511e5 Avoid freeing buffer twice in case of error. 2022-10-11 18:09:38 +02:00
Tor Andersson
3f71a1c946 Fast path for "simple" arrays.
An array without holes and with only integer properties can be represented
with a "flat" array part that allows for O(1) property access.

If we ever add a non-integer property, create holes in the array,
the whole array is unpacked into a normal string-keyed object.

Also add fast integer indexing to be used on these arrays, before falling
back to converting the integer to a string property lookup.

Use JS_ARRAYLIMIT to restrict size of arrays to avoid integer overflows and out
of memory thrashing.
2022-09-08 13:54:14 +02:00
Tor Andersson
ac03b95b18 Bug 705775: Fix double fclose in pretty-printing tool. 2022-08-23 11:16:42 +02:00
Wessel Dankers
1cbf19e7a9 Makefile: fix parallel builds
The parent directory wasn't created when generating the .pc file,
causing it to fail in highly parallel builds.
2022-08-05 13:13:21 +02:00
Tor Andersson
3451b6ca96 Guard state initialization with try to avoid panic in initialization. 2022-06-09 15:53:51 +02:00