Commit graph

24514 commits

Author SHA1 Message Date
Timothy Flynn
66c31a0c07 LibJS: Implement RegExp.prototype [ @@search ] with UTF-16 code units 2021-07-23 23:06:57 +01:00
Timothy Flynn
2c023157e9 LibJS: Implement RegExp.prototype [ @@match ] with UTF-16 code units 2021-07-23 23:06:57 +01:00
Timothy Flynn
b1ea9c20b0 LibJS: Implement RegExp.prototype.{exec,test} with UTF-16 code units
This converts RegExpExec to perform matching with UTF-16 strings. As a
very temporary stop-gap, this adds overloads to RegExpExec and friends
for both UTF-8 and UTF-16 strings. This is only needed until the rest
of RegExp.prototype is UTF-16 capable.

This also addresses a FIXME regarding code point index correction in
RegExpExec when the Unicode flag is set.
2021-07-23 23:06:57 +01:00
Timothy Flynn
a0c19deb80 LibJS: Implement RegExpCreate/RegExpInitialize closer to the spec
RegExpInitialize specifies how the pattern string should be created
before passing it to [[RegExpMatcher]]. Rather than passing it as-is,
the string should be converted to code points and back to a "List" (if
the Unicode flag is present), or as a "List" of UTF-16 code units.
Further. the spec requires that we keep both the original pattern string
and this parsed string in the RegExp object.

The caveat is that the LibRegex parser further requires any multi-byte
code units to be escaped (as "\unnnn"). Otherwise, the code unit is
recognized as individual UTF-8 bytes.
2021-07-23 23:06:57 +01:00
Timothy Flynn
345ef6abba LibRegex: Support ECMA-262 Unicode escapes of the form "\u{code_point}"
When the Unicode flag is set, regular expressions may escape code points
by surrounding the hexadecimal code point with curly braces, e.g. \u{41}
is the character "A".

When the Unicode flag is not set, this should be considered a repetition
symbol - \u{41} is the character "u" repeated 41 times. This is left as
a TODO for now.
2021-07-23 23:06:57 +01:00
Timothy Flynn
0e6375558d AK+LibRegex: Partially implement case insensitive UTF-16 comparison
This will work for ASCII code points. Unicode case folding will be
needed for non-ASCII.
2021-07-23 23:06:57 +01:00
Timothy Flynn
47f6bb38a1 LibRegex: Support UTF-16 RegexStringView and improve Unicode matching
When the Unicode option is not set, regular expressions should match
based on code units; when it is set, they should match based on code
points. To do so, the regex parser must combine surrogate pairs when
the Unicode option is set. Further, RegexStringView needs to know if
the flag is set in order to return code point vs. code unit based
string lengths and substrings.
2021-07-23 23:06:57 +01:00
Timothy Flynn
2e45e52993 AK: Add UTF-16 helper methods required for use within LibRegex
To be used as a RegexStringView variant, Utf16View must provide a couple
more helper methods. It must also not default its assignment operators,
because that implicitly deletes move/copy constructors.
2021-07-23 23:06:57 +01:00
Idan Horowitz
1d76be97f5 LibJS: Implement Temporal.PlainDate.prototype.inLeapYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
c9ae7e1af1 LibJS: Implement Temporal.Calendar.prototype.inLeapYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
dd15fc471c LibJS: Implement Temporal.PlainDate.prototype.monthsInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
342172da37 LibJS: Implement Temporal.Calendar.prototype.monthsInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
b1dd09840b LibJS: Implement Temporal.PlainDate.prototype.daysInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
7f27035342 LibJS: Implement Temporal.Calendar.prototype.daysInYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
3160540d0e LibJS: Implement Temporal.PlainDate.prototype.daysInMonth 2021-07-23 22:00:23 +01:00
Idan Horowitz
69c8b8e8bd LibJS: Implement Temporal.Calendar.prototype.daysInMonth 2021-07-23 22:00:23 +01:00
Idan Horowitz
2150f5b374 LibJS: Implement Temporal.PlainDate.prototype.daysInWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
623df361e6 LibJS: Implement Temporal.Calendar.prototype.daysInWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
2cf582436f LibJS: Implement Temporal.PlainDate.prototype.weekOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
d22fe25643 LibJS: Implement Temporal.Calendar.prototype.weekOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
d561535ac9 LibJS: Implement Temporal.PlainDate.prototype.dayOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
c0e7761758 LibJS: Implement Temporal.Calendar.prototype.dayOfYear 2021-07-23 22:00:23 +01:00
Idan Horowitz
bcbfd5b280 LibJS: Implement Temporal.PlainDate.prototype.dayOfWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
339b0a17e8 LibJS: Implement Temporal.Calendar.prototype.dayOfWeek 2021-07-23 22:00:23 +01:00
Idan Horowitz
59dc0e8421 LibJS: Implement Temporal.PlainDate.prototype.day 2021-07-23 22:00:23 +01:00
Idan Horowitz
8a20f258f0 LibJS: Implement Temporal.Calendar.prototype.day 2021-07-23 22:00:23 +01:00
Idan Horowitz
d9414e465a LibJS: Implement Temporal.PlainDate.prototype.monthCode 2021-07-23 22:00:23 +01:00
Idan Horowitz
9d9ba29cae LibJS: Implement Temporal.Calendar.prototype.monthCode 2021-07-23 22:00:23 +01:00
Idan Horowitz
a0af9b11fb LibJS: Implement Temporal.PlainDate.prototype.month 2021-07-23 22:00:23 +01:00
Idan Horowitz
3bec18432a LibJS: Implement Temporal.Calendar.prototype.month 2021-07-23 22:00:23 +01:00
Idan Horowitz
8434ca6c4b LibJS: Implement Temporal.PlainDate.prototype.year 2021-07-23 22:00:23 +01:00
Idan Horowitz
3895a8354d LibJS: Implement Temporal.Calendar.prototype.year 2021-07-23 22:00:23 +01:00
Idan Horowitz
9fa8f19a0f LibJS: Implement Temporal.PlainDate.prototype.withCalendar 2021-07-23 22:00:23 +01:00
Idan Horowitz
8123e957e3 LibJS: Add missing PlainDateTime case in ToTemporalDate 2021-07-23 22:00:23 +01:00
Gunnar Beutner
54fb5637e7 Kernel: Add missing .globl definitions
This ensures that we can properly take the address of these symbols in
other code.
2021-07-23 22:13:43 +02:00
Gunnar Beutner
8642c831cf Kernel: Mark a few more things as READONLY_AFTER_INIT 2021-07-23 20:23:09 +02:00
Gunnar Beutner
18f8d08b98 Kernel: Always build the kernel without default libs
When building the kernel from within SerenityOS we would link it against
default libs which doesn't really make sense to me.
2021-07-23 19:06:51 +02:00
Gunnar Beutner
a6c4a4d2fc Kernel: Make some of the assembly code position-independent on x86_64 2021-07-23 19:06:51 +02:00
Gunnar Beutner
412ce31f7f Prekernel: Don't build the prekernel as a PIE image
This is unnecessary because the prekernel is always loaded at a known
base address.
2021-07-23 19:06:51 +02:00
Gunnar Beutner
0edc17ee76 Kernel: Make -pie work for x86_64 2021-07-23 19:06:51 +02:00
Brian Gianforcaro
9d8482c3e8 Kernel: Use StringView when parsing pledges in sys$pledge(..)
This ensures no potential allocation as in some cases the pledge char*
could be promoted to AK::String by the compiler to execute the
comparison.
2021-07-23 19:02:25 +02:00
Brian Gianforcaro
c2282ee28d Tests: Add test coverage for sys$pledge(..) argument validation 2021-07-23 19:02:25 +02:00
Brian Gianforcaro
e4b86aa5d8 Kernel: Fix bug where we half apply pledges in sys$pledge(..)
This bug manifests it self when the caller to sys$pledge() passes valid
promises, but invalid execpromises. The code would apply the promises
and then return an error for the execpromises. This leaves the user in
a confusing state, as the promises were silently applied, but we return
an error suggesting the operation has failed.

Avoid this situation by tweaking the implementation to only apply the
promises / execpromises after all validation has occurred.
2021-07-23 19:02:25 +02:00
Brian Gianforcaro
36ff717c54 Kernel: Migrate sys$pledge to use the KString API
This avoids potential unhandled OOM that's possible with the old
copy_string_from_user API.
2021-07-23 19:02:25 +02:00
Brian Gianforcaro
8acbe03342 Kernel: Annotate kernel_base and friends as READONLY_AFTER_INIT
We don't want kernel_base to be modifiable by an attacker or a stray
memory scribbler bug, so lets mark it as READONLY_AFTER_INIT.
2021-07-23 19:02:25 +02:00
Brian Gianforcaro
fa448456a9 Tests: Add test coverage for sys$unveil(..) argument validation 2021-07-23 19:02:25 +02:00
Brian Gianforcaro
baec9e2d2d Kernel: Migrate sys$unveil to use the KString API
This avoids potential unhandled OOM that's possible with the old
copy_string_from_user API.
2021-07-23 19:02:25 +02:00
Brian Gianforcaro
2e7728bb05 Kernel: Use StringView literals for fs_type match in sys$mount(..) 2021-07-23 19:02:25 +02:00
Brian Gianforcaro
a3787b9db7 Kernel: Remove another ARCH ifdef using RegisterState::flags() 2021-07-23 19:02:25 +02:00
Itamar
8241a6c8eb TextEditor: Allow starting with a file argument that doesn't exist
If TextEditor is started with an argument for a file that doesn't
exist, we now allow editing it.

The file will be created once it is saved.
2021-07-23 21:19:30 +04:30