Commit graph

60412 commits

Author SHA1 Message Date
Ali Mohammad Pur 5485e2a940 RequestServer: Avoid race condition between timeout and socket creation
Part of this issue was fixed in 89877b3f40
but that only addressed the first layer of deferred_invoke, ignoring the
second one (which would cause a race if a request was sent to a host
immediately following a timeout event from the same host).
Fixes #23840.
2024-04-05 08:13:58 +02:00
Shannon Booth 973cc67e81 LibWeb: Implement <a> element activation behavior for ismap <img>s
This allows you to click on a <img> that has an ismap attribute, and
will result in the navigation URL having the coordinates appended as a
query to the URL.
2024-04-04 17:17:57 -04:00
Shannon Booth 8af7b64acc LibWeb: Fix typo passing through url_string in 'follow the hyperlink'
It's a little bit confusing and awkward that we have `url` _and_
`url_string` here, but let's just fix the typo so that we correctly pass
through the URL with the given suffix (if any).

Currently, nothing is actually passing through this suffix - so it
doesn't fix anything yet, but it becomes relevant in the next commit.
2024-04-04 17:17:57 -04:00
Timothy Flynn 5d5b69578f LibWeb: Handle <input> element type changing to the image button state
The spec has special steps specific to the image button state to load
the element's image URL.
2024-04-04 21:06:45 +02:00
Timothy Flynn 0e774fe780 LibWeb: Recreate the <input> shadow tree when the type attribute changes
This is often used on login forms, for example, to toggle the visibility
of a password. The site will change the <input> element's type to "text"
to allow the password to show.
2024-04-04 21:06:45 +02:00
Timothy Flynn 06a3ca734e LibWeb: Handle changes to an input element's "multiple" attribute
Update the shadow tree so that the attribute is reflected on the page.
2024-04-04 21:06:45 +02:00
Timothy Flynn 6af7f7e0f5 LibWeb: Update placeholder visibility when the placeholder value changes
Otherwise, setting a placeholder on an element that previously did not
have a placeholder would have no visible effect.
2024-04-04 21:06:45 +02:00
stelar7 9f3c3925e0 LibWeb: Implement skeleton of SubtleCrypto.deriveKey 2024-04-04 21:00:40 +02:00
stelar7 abf55fe33d LibWeb: Implement PBKDF2 getKeyLength for SubtleCrypto 2024-04-04 21:00:40 +02:00
stelar7 19bb62d60e LibWeb: Implement PBKDF2 deriveBits for SubtleCrypto 2024-04-04 21:00:40 +02:00
stelar7 daf2c4ce46 LibWeb: Implement skeleton of SubtleCrypto.deriveBits 2024-04-04 21:00:40 +02:00
Nico Weber b17a9ad82a Tests/JBIG2: Add test cases for custom adaptive template pixels
I manually wrote a bunch of .ini files and ran this script to
produce the files:

    #!/bin/bash
    set -eu

    J=$HOME/Downloads/T-REC-T.88-201808-I\!\!SOFT-ZST-E/Software
    J=$J/JBIG2_SampleSoftware-A20180829/source/jbig2

    for t in '' template1- template2- template3-; do
      for p in '' '-tpgdon'; do
        i=${t}customat$p
        echo $i.ini
        cat $i.ini
        $J -i Tests/LibGfx/test-inputs/bmp/bitmap -f bmp -o bitmap-$i \
            -F jb2 -ini $i.ini
        cp bitmap-$i.jb2 Tests/LibGfx/test-inputs/jbig2/bitmap-$i.jbig2
      done
    done

The script's output (which shows the .ini file contents) was:

```
% ./make-custom-at.sh
customat.ini
-Gen -Seg 1
-Gen -Param -ATX1 -4
-Gen -Param -ATY1 -5
-Gen -Param -ATX2 6
-Gen -Param -ATY2 -7
-Gen -Param -ATX3 -8
-Gen -Param -ATY3 -9
-Gen -Param -ATX4 10
-Gen -Param -ATY4 -11
ENC Start ===>complete
customat-tpgdon.ini
-Gen -Seg 1
-Gen -Param -ATX1 -4
-Gen -Param -ATY1 -5
-Gen -Param -ATX2 6
-Gen -Param -ATY2 -7
-Gen -Param -ATX3 -8
-Gen -Param -ATY3 -9
-Gen -Param -ATX4 10
-Gen -Param -ATY4 -11
-Gen -Param -TpGDon 1
ENC Start ===>complete
template1-customat.ini
-Gen -Seg 1
-Gen -Param -Template 1
-Gen -Param -ATX1 17
-Gen -Param -ATY1 -2
ENC Start ===>complete
template1-customat-tpgdon.ini
-Gen -Seg 1
-Gen -Param -Template 1
-Gen -Param -ATX1 17
-Gen -Param -ATY1 -2
-Gen -Param -TpGDon 1
ENC Start ===>complete
template2-customat.ini
-Gen -Seg 1
-Gen -Param -Template 2
-Gen -Param -ATX1 17
-Gen -Param -ATY1 -2
ENC Start ===>complete
template2-customat-tpgdon.ini
-Gen -Seg 1
-Gen -Param -Template 2
-Gen -Param -ATX1 17
-Gen -Param -ATY1 -2
-Gen -Param -TpGDon 1
ENC Start ===>complete
template3-customat.ini
-Gen -Seg 1
-Gen -Param -Template 3
-Gen -Param -ATX1 17
-Gen -Param -ATY1 -2
ENC Start ===>complete
template3-customat-tpgdon.ini
-Gen -Seg 1
-Gen -Param -Template 3
-Gen -Param -ATX1 17
-Gen -Param -ATY1 -2
-Gen -Param -TpGDon 1
ENC Start ===>complete
```
2024-04-04 11:44:50 -04:00
Nico Weber a0a14296f9 LibGfx/JBIG2: Implement support for custom adaptive template pixels
...in the generic region decoding procedure (not yet in the generic
refinement region procedure). Not yet for EXTTEMPLATE though.

I haven't seen these being used in the wild, but:
* I want to optimize this code some, and it's probably good if it
  is feature complete (and well-tested) before being optimized
* Other PDF engines implement support for this
* The Pattern/Halftone feature (which we don't yet implement either,
  but which I'd like to implement because see previous two bullets)
  calls the generic region decoding procedure with custom adaptive
  template pixels
2024-04-04 11:44:50 -04:00
Nico Weber f570678bf0 LibPDF: Invert image masks used as alpha too
Fixes #23824, a regression from the first commit in #23781.
2024-04-04 06:55:08 -04:00
Simon Wanner bf6e3e5e28 LibWebView: Avoid CPU% precision loss by doing the float cast later
After some uptime the total_time_scheduled can get too big for accurate
float subtraction.
It's better to do the subtraction in u64 and use float only for the
division later on.
2024-04-04 12:49:53 +02:00
Timothy Flynn c5c5e52c24 AK: Disallow calling ByteString methods that return a view on rvalues
This prevents, for example:

    StringView view = ByteString { "foo" }.view();

This prevents a class of potential UAF.
2024-04-04 11:23:21 +02:00
Timothy Flynn de80f544d8 AK: Disallow calling String methods that return a view on rvalues
This prevents, for example:

    StringView view = "foo"_string.bytes_as_string_view();

This prevents a class of potential UAF.
2024-04-04 11:23:21 +02:00
Timothy Flynn 38ca0f8db9 LibDesktop: Avoid UAF when launching a process with escalation
The value returned by executable() was a temporarily allocated string
which we were holding a view into.
2024-04-04 11:23:21 +02:00
Timothy Flynn e57d739705 HackStudio: Avoid UAF when loading the GML preview
The value returned by editor().text() was a temporarily allocated string
which we were holding a view into.
2024-04-04 11:23:21 +02:00
Timothy Flynn decc00dcdf LibGLSL: Avoid UAF when creating a preprocessor instance
The intialization of Definition::value allocates a string that we were
holding a view into. Store the result as a String to keep it alive; its
only usage is passing it to GenericLexer in another function.
2024-04-04 11:23:21 +02:00
Timothy Flynn 3dee703227 LibWeb: Avoid UAF parsing an XML document's charset
The value returned by get_final_encoding() was a temporarily allocated
string which we were holding a view into.
2024-04-04 11:23:21 +02:00
Timothy Flynn 48fb343230 LibWeb: Change HTMLParser's factory to accept the encoding as StringView
No need to force an allocation. This makes a future patch a bit simpler,
where we will have the encoding as a String. With this patch, we won't
have to convert it to a ByteString.
2024-04-04 11:23:21 +02:00
Timothy Flynn 683c08744a Userland: Avoid some conversions from rvalue strings to StringView
These are all actually fine, there is no UAF here. But once e.g.
`ByteString::view() &&` is deleted, these instances won't compile.
2024-04-04 11:23:21 +02:00
Timothy Flynn 23b25333a5 LibCrypto: Avoid needless ByteString usage in unit tests 2024-04-04 11:23:21 +02:00
Timothy Flynn b5f22b6e90 AK+Userland: Remove some needlessly explicit conversions to StringView 2024-04-04 11:23:21 +02:00
Timothy Flynn c23060e21b Userland: Avoid some now-unneeded explicit conversions to Bytes 2024-04-04 11:23:21 +02:00
Timothy Flynn e0bddbb65e AK: Add a Stream::write_until_depleted overload for string types
All string types currently have to invoke this function as:

    stream.write_until_depleted("foo"sv.bytes());

This isn't very ergonomic, but more importantly, this overload will
allow String/ByteString instances to be written in this manner once
e.g. `ByteString::view() &&` is deleted.
2024-04-04 11:23:21 +02:00
Timothy Flynn c7ea710b55 AK: Return a constant reference from JsonValue::as_string
Rather than making a copy of the held string, this returns a reference
so that expressions like the following:

    do_something(json.as_string().view());

are not disallowed once `ByteString::view() &&` is deleted.
2024-04-04 11:23:21 +02:00
Andrew Kaster 6d38d55fc8 LibWebView: Collect memory and cpu usage for helpers on Linux 2024-04-04 09:41:01 +02:00
0x4261756D a005aae497 LibJS: Add missing Base::visit_edges() in FetchAlgorithms and Navigable
These are empty calls since `Base` is JS::Cell  but they *are* missing
and LibJSGCVerifier complains otherwise.
2024-04-04 07:50:13 +02:00
0x4261756D f489c3d9c2 LibJSGCVerifier: Fix false positives in HeapFunction::visit_edges()
clang doesn't make all `Base::visit_edges()` calls CXXMemberCallExprs
This would lead to false positives like in HeapFunction,
where the matcher would fail to match and report a warning.
Also previously the matcher would succeed
if the visited class is missing the call to `Base::visit_edges()`
but an included class has a correct method.

The new matcher checks the current class for `visit_edges`-overrides
and matches all `visit_edges`-memberExprs inside,
checking those for starting with `Base::`.
This seems to get rid of the false positives
and should be more correct detecting missing calls.
2024-04-04 07:50:13 +02:00
0x4261756D 7743dcf4a9 LibJSGCVerifier: Fix dangling-reference errors
When building, clang would throw errors about dangling references.
Extracting `template_args` to a variable before the loop and
indexing into that seems to fix the errors.
2024-04-04 07:50:13 +02:00
Andrew Kaster bf722d49b0 LibWeb: Remove WebContent include from SVGDecodedImageData
This is a layering violation, and is not used. Caught by the gn build.
2024-04-04 07:47:16 +02:00
Timothy Flynn 69b5d7c0e6 LibWeb: Avoid UAF when encoding a fetch request body via URLSearchParams 2024-04-03 17:14:01 -04:00
Andreas Kling d91d6ee205 LibWeb: Stop leaking entire realms via Blob URLs
This patch implements the File API spec's supplemental steps for
document's "unloading document cleanup steps" so that we now remove blob
URLs associated with the document's relevant settings object when the
document is being unloaded.

Fixes two realm leaks when running our test suite.
2024-04-03 22:20:50 +02:00
Aliaksandr Kalenik 696cf7b9fb LibWeb: Fix "destroy the child navigable" to call Document::destroy()
f66d33423b was not sufficient to ensure
document destruction when a child navigable is destroyed. This is
because a navigable was remove from the set of all navigables too early
which led to `Navigable::navigable_with_active_document()` being unable
to find a navigable that is still in the process of destruction.

This change solves that by making all steps of a navigable destruction
to happen in afterAllDestruction callback.

Unfortunately, writing a test to verify document destruction is
challenging because no events are emitted to indicate that it has
happened.
2024-04-03 21:17:57 +02:00
stelar7 35676491ec LibWeb: Implement ED25519 verify for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7 9ad10566b2 LibWeb: Implement ED25519 sign for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7 ec015034bd LibWeb: Implement ED25519 generateKey for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7 069295d132 LibWeb: Improve NotSupported error message for normalize_an_algorithm 2024-04-03 13:10:01 -06:00
stelar7 54a3ffcd42 LibCrypto: Add early exit to SECP.verify if signature is invalid 2024-04-03 13:10:01 -06:00
stelar7 ae230c9150 LibWeb: Implement most of ECDSA verify for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7 6906b7c1e6 LibWeb: Implement skeleton of SubtleCrypto.verify 2024-04-03 13:10:01 -06:00
stelar7 bc2a5e24bc LibWeb: Implement skeleton of ECDSA sign for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7 41449814db LibWeb: Implement generateKey for ECDSA 2024-04-03 13:10:01 -06:00
stelar7 cfae6523be LibWeb: Implement skeleton of SubtleCrypto.sign 2024-04-03 13:10:01 -06:00
Andrew Kaster d1fdfead54 LibWebView+Browser: Collect memory and cpu usage for helpers on Serenity 2024-04-03 20:56:33 +02:00
Timothy Flynn d6c8218089 Ladybird/Qt: Show the tab bar by default
We currently only show the tab bar when we have more than one tab open.
This has caused confusion in the past, as it's a bit less obvious that
the browser supports tabs. For example:

https://hackaday.com/2023/10/10/jennys-daily-drivers-serenityos-and-in-particular-ladybird/
"it’s a single window with no tabs"
2024-04-03 20:56:04 +02:00
Timothy Flynn ecce4ad426 Ladybird/Qt: Set the tab tooltip to its full title
If a tab's title is cut off due to its size, setting a tool tip will
allow for viewing the full title.
2024-04-03 20:56:04 +02:00
Timothy Flynn 2713d4651d Ladybird/Qt: Specify a minimum and maxium tab width
By default, Qt will grow the width of a tab button to fit the title text
of the tab. For long titles or file:// URLs, this looks rather bad. This
sets a min/max tab width to prevent such infinite growth.

To do this, we have to subclass both QTabWidget and QTabBar, because the
functions to be called/overridden are protected.
2024-04-03 20:56:04 +02:00