Commit graph

56230 commits

Author SHA1 Message Date
Strawby
df6668ff5b Calculator: Add Manual link to the help-context-menu 2023-11-08 16:26:23 +00:00
Strawby
056070ff85 3DFileViewer: Add Manual link to the help-context-menu 2023-11-08 16:26:23 +00:00
Sebastian Bernauer
8eb9c2dc54 LibJS/JIT: Add fast path for number comparisons
So far only less_than was using a fast path. This commits uses the same
path for less_than_equals, greater_than and greater_than_equals.
2023-11-08 14:11:51 +01:00
Tim Ledbetter
ff81513634 Shell: Avoid infinite loop when parsing heredoc entry in POSIX mode
Previously, the shell would enter an infinite loop when attempting to
parse a heredoc entry within a `$(` command substitution.
2023-11-08 15:04:08 +03:30
Aliaksandr Kalenik
c170dd323e LibJS: Make eval() prevent GetGlobal usage less aggressively
Before usage of GetGlobal was prevented whenever eval() is present in
the scope chain.

With this change GetGlobal is emitted for `g` in the following program:
```js
function screw_everything_up() {
    eval("");
}

var g;
g;
```

It makes Octane/mandreel.js benchmark run 2x faster :)
2023-11-08 10:07:56 +01:00
Matthew Olsson
1ca46afa2f LibWeb: Add the Animation IDL object 2023-11-08 09:58:18 +01:00
Matthew Olsson
0df06ce273 LibWeb: Add the AnimationEffect IDL object 2023-11-08 09:58:18 +01:00
Matthew Olsson
e03e710d1b IDLGenerators: Support nullable dictionary members with default values
When wrapping dictionary members, generate_wrap_statement was called
with the pattern "auto {} = ...", where "..." was determined based on
the variable's type. However, in generate_wrap_statement, if a type is
nullable it generates an if statement, so this would end up generating
something along the lines of

    if (!retval.member.has_value()) {
    	auto wrapped_member0_value = JS::js_null();
    } else {
    	auto wrapped_member0_value = JS::Value(...);
    }

...which makes the declaration inaccessible. It now generates the same
code, but the "auto" declaration (now an explicit JS::Value declaration)
is outside of the if-statement.
2023-11-08 09:58:18 +01:00
Matthew Olsson
111e0159ff IDLGenerators: Allow specifying default non-empty string values 2023-11-08 09:58:18 +01:00
Luke Wilde
fc42c75a0c LibWeb: Make Window.postMessage closer to the spec
The main issues are using Structured{Serialize,Deserailize} instead of
Structured{Serialize,Deserialize}WithTransfer and the temporary
execution context usage for StructuredDeserialize.

Allows Discord to load once again, as it uses a postMessage scheduler
to render components, including the main App component. The callback
checked the (previously) non-existent source attribute of the
MessageEvent and returned if it was not the main window.

Fixes the Twitch cookie consent banner saying "failed integrity check"
for unknown reasons, but presumably related to the source and origin
attributes.
2023-11-08 09:55:24 +01:00
Luke Wilde
464cc55b16 LibWeb: Default initialize strings in MessageEventInit 2023-11-08 09:55:24 +01:00
Luke Wilde
1607b2c978 LibWeb: Add MessageEvent.source 2023-11-08 09:55:24 +01:00
Luke Wilde
eaa3b85864 LibWeb: Fix "ParameterizedTypeType" -> "ParameterizedType" typo for IDL 2023-11-08 09:55:24 +01:00
Luke Wilde
34cd69e623 LibWeb: Add support for WindowProxy in IDL -> CPP, unions, constructors 2023-11-08 09:55:24 +01:00
Luke Wilde
280199fb08 LibWeb: Recognise MessagePort as a platform object in IDL generator 2023-11-08 09:55:24 +01:00
Tim Ledbetter
e510d81567 Assistant: Prioritize results which exactly match a query 2023-11-08 09:52:24 +01:00
Tim Ledbetter
e1099a1757 Fuzzers: Use a single fuzzer to test all LibTextCodec encodings
This commit replaces the 5 fuzzers that previously tested LibTextCodec
with a single fuzzer. We now rely on the fuzzer to generate the
encoding and separate it from the encoded data with a magic separator.
This increases the overall coverage of LibTextCodec and eliminates the
possibility of the same error being generated by multiple fuzzers.
2023-11-08 09:39:49 +01:00
Tim Ledbetter
7d717986de Lagom: Copy fuzzer dictionary files to Oss-Fuzz $OUT directory
When building fuzzers for Oss-Fuzz using `BuildFuzzers.sh --oss-fuzz`,
fuzzer dictionary files are now copied to the `$OUT` directory. This
allows them to be used automatically by the corresponding fuzzer.
2023-11-08 09:39:49 +01:00
Tim Ledbetter
33ad384a7d Fuzzers: Add a DNS packet fuzzer 2023-11-08 09:38:36 +01:00
Tim Ledbetter
2fbaeb9694 LibDNS: Prevent malformed DNS packets from causing buffer overflows 2023-11-08 09:38:36 +01:00
Tim Ledbetter
4e3b59a4bb LibDNS: Prefer spans over raw pointers when parsing DNS packets
This means we don't have to keep track of the pointer and size
separately.
2023-11-08 09:38:36 +01:00
Tim Ledbetter
c1d7a51391 LibGfx/ICC: Avoid buffer overrun when creating TextDescriptionTagData
We now validate that the offsets used cannot overflow, preventing
possible buffer overruns.
2023-11-08 09:37:30 +01:00
Tim Ledbetter
4b995542c4 LibIMAP: Make parsing of atom data fallible
We now return an error where `parse_atom()` would have previously
returned an empty StringView. This is consistent with RFC3501, which
says that an atom consists of one or more characters.

This prevents a few cases where parsing an invalid atom could lead to
an infinite loop.
2023-11-08 09:36:37 +01:00
Tim Ledbetter
b96a5f4265 LibGfx/ILBM: Avoid overflow when creating bitplane data buffer 2023-11-08 09:36:01 +01:00
Tim Ledbetter
5e1017bcf1 LibGfx/ILBM: Avoid buffer overrun when reading bitplane data 2023-11-08 09:36:01 +01:00
Tim Ledbetter
f56ae8c0e9 LibGfx/ILBM: Ensure CMAP chunk size matches expected value
The color map should be 3 bytes per pixel and should contain
`2^nPlanes` pixels. We now return an error if the color map isn't the
size we expect.
2023-11-08 09:36:01 +01:00
Tim Ledbetter
61eb754f63 LibGfx/ILBM: Add validation for header fields
We now exit early if a header field is set to a value that we don't
currently support.
2023-11-08 09:36:01 +01:00
Tim Ledbetter
bed7b33daa LibGfx/ILBM: Don't attempt to decode a BODY chunk without a color map
While this isn't disallowed by the specification, it is not something
we currently support. Instead of crashing we now return an error in
this case.
2023-11-08 09:36:01 +01:00
Tim Ledbetter
75731f9c50 LibGfx/ILBM: Avoid buffer overruns when decompressing data 2023-11-08 09:36:01 +01:00
Tim Ledbetter
ae6c39e501 LibGfx/ILBM: Ensure decompressed body chunk data is the correct length 2023-11-08 09:36:01 +01:00
Tim Ledbetter
39f7f1e84c Tests: Use more representative test cases for ILBM regression tests
Previously, the regression tests for OSS-Fuzz issues 62033 and 63296
used test case files directly from OSS-Fuzz. These files are invalid
in multiple ways because they have been generated by a fuzzer. This
commit replaces these files with ones that only expose the issue being
tested.
2023-11-08 09:36:01 +01:00
Sam Atkins
21f2f09df4 LibGfx: Remove bit casting in OpenType CBDT table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
4e944e676b LibGfx: Use to_underlying() to compare ValueFormat enum values
This means we no longer do a bitwise and of a u16 and i16, which feels a
little sketchy.
2023-11-08 09:34:09 +01:00
Sam Atkins
74e5fff77a LibGfx: Reduce bit casting in OpenType GPOS table after construction
Read the basic lists as spans, and use those when looking for kerning.

Kerning lookup still does bit-casting for now. As for CBLC, the data is
a bit complicated.
2023-11-08 09:34:09 +01:00
Sam Atkins
2a4d7a193e LibGfx: Define and use OpenType data types for struct definitions
A few closely-related changes:
- Move our definitions of the OpenType spec's "data types" into their
  own header file.
- Add definitions for the integer types there too, for completeness.
  (Plus Uint16 matches the spec term, and is less verbose than
  BigEndian<u16>.)
- Include Traits for the non-BigEndian types so that we can read them
  from Streams. (BigEndian<integer-type> already has this.)
- Use the integer types in our struct definitions.

As a bonus, this fixes a bug in Hmtx, which read the left-side bearings
as i16 instead of BigEndian<i16>.
2023-11-08 09:34:09 +01:00
Sam Atkins
a28f035d76 LibGfx: Reduce bit casting in OpenType CBLC table after construction
The subtables are still read at use-time for now. I'm sure we could
build some kind of wrapper structures for them though.
2023-11-08 09:34:09 +01:00
Sam Atkins
3c7d654182 LibGfx: Remove bit casting in OpenType Kern table after construction
Do more checks at load time, including categorizing the subtables and
producing our own directory of them.

The format for Kern is a little complicated, so use a Stream instead of
manual offsets.
2023-11-08 09:34:09 +01:00
Sam Atkins
1519290989 AK: Cast pointer in FixedMemoryStream::read_in_place(count)
I didn't notice this before because I only ever called it with u8. Oops!
2023-11-08 09:34:09 +01:00
Sam Atkins
89b35c6dc8 LibGfx: Remove bit casting in OpenType Name table after construction
Store the name records as a span, and a separate bytes span for the
string data.
2023-11-08 09:34:09 +01:00
Sam Atkins
fe2e1a0282 LibGfx: Remove bit casting in OpenType OS2 table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
d4e1305413 LibGfx: Make OpenType versioned tables more consistent
Maxp had the shared fields duplicated, and OS2 embedded each version's
struct in the next. Instead, let's use inheritance to avoid duplicating
shared fields while still allowing them to be directly accessed.

While I'm at it, rename the Maxp and GPOS table structs to just be
VersionX_Y, because they're not ambiguous with anything else.

LibGfx: Rename GPOSHeader to HeaderVersion1_0

Because there's a version 1.1 as well, which we'll eventually want to
support.
2023-11-08 09:34:09 +01:00
Sam Atkins
75376d6834 LibGfx: Remove bit casting in OpenType Hmtx table after construction
Store the variable-length data in Spans instead.
2023-11-08 09:34:09 +01:00
Sam Atkins
cef4d4821b LibGfx: Remove bit casting in OpenType Maxp table after construction
Store references to both versions of the struct in a Variant, and reject
versions we don't support.
2023-11-08 09:34:09 +01:00
Sam Atkins
e4b3ee09e2 LibGfx: Remove bit casting in OpenType Hhea table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
dcbe302f83 LibGfx: Remove bit casting in OpenType Head table after construction 2023-11-08 09:34:09 +01:00
Sam Atkins
72483673d2 LibGfx: Use ErrorOr to report failure to load OpenFont tables 2023-11-08 09:34:09 +01:00
Sam Atkins
1ab03ff963 LibGfx: Read OpenType table directory using structs and streams 2023-11-08 09:34:09 +01:00
Sam Atkins
5455ecf650 LibGfx: Remove OpenType::Font::m_buffer
At first glance this looks like it holds the memory that the various
slices point into... but it actually doesn't own that memory. Nobody
uses m_buffer, so it serves no purpose.
2023-11-08 09:34:09 +01:00
Sam Atkins
984a2c314b LibGfx: Read OpenType TTCHeaderV1 as a struct
Also check that the requested font index actually exists in the font
collection.
2023-11-08 09:34:09 +01:00
Sam Atkins
1a6da4fbf2 LibGfx: Mark OpenType file data structs as packed, and assert sizes
Some of these are odd sizes. We managed not to insert padding because
BigEndian is itself marked as packed, but let's be explicit instead of
relying on that. :^)
2023-11-08 09:34:09 +01:00