Commit Graph

60485 Commits

Author SHA1 Message Date
Fabian Dellwing
e511c553a8 tail: Implement byte mode into tail
This works exactly the same as with lines but with bytes instead.
2024-04-05 15:30:41 -06:00
Fabian Dellwing
91e944d793 tail: Choose correct line to output from
Previously we did not match the behaviour of coreutils in our from
start modus and some edge cases with 0 and 1 lines were broken.
2024-04-05 15:30:41 -06:00
stelar7
7c7f01b82f LibWeb: Add RSAOAEP.exportKey for the pkcs8 format 2024-04-05 21:53:12 +02:00
stelar7
b3e112fa51 LibCrypto: Fix off-by-one error when bit count is a multiple of 256 2024-04-05 21:53:12 +02:00
stelar7
f9dd028119 LibWeb: Add RSAOAEP.exportKey for the spki format 2024-04-05 21:53:12 +02:00
Idan Horowitz
1fd6673f87 LibJSGCVerifier: Support building & running with the Lagom build 2024-04-05 21:49:13 +02:00
Nico Weber
2d4964b945 LibGfx/JBIG2: Support custom adaptive template pixels in refinement
The implementation is very similar to #23831.

I created the test exactly like in #23713, except that I replaced the
last four lines in the ini file with:

```
-txt -Param -rATX1 10
-txt -Param -rATY1 -1
-txt -Param -rATX2 4
-txt -Param -rATY2 15
```
2024-04-05 21:32:18 +02:00
Nico Weber
154d0bb458 LibGfx/JBIG2: Extract check_valid_adaptive_template_pixel()
No behavior change.
2024-04-05 21:32:18 +02:00
Nico Weber
200e36aad3 Tests/JBIG2: Remove test_jbig2_size
It's redundant with test_jbig2_decode nowadays.
2024-04-05 21:32:18 +02:00
Aliaksandr Kalenik
188775c4e3 LibWeb: Add a test for history.pushState() that uses setTimeout() 2024-04-05 21:28:41 +02:00
Aliaksandr Kalenik
4ca715d2ef LibWeb: Skip SHTQ processing if ongoing task form queue is not finished
Fixes a bug when session history traversal queue task could be
interrupted by another SHTQ task execution. For example:
1. SHTQ timer callback starts executing a task from the queue.
2. spin_until() is invoked during task execution.
3. SHTQ timer callback starts executing a task from the queue.
2024-04-05 21:28:41 +02:00
Aliaksandr Kalenik
00531573a4 LibWeb: Remove SessionHistoryTraversalQueue::process()
...because existance of this method conflicts with the purpose of
having a queue as it allows to start executing next task in the middle
of ongoing task.

For example:

1. SHTQ timer starts executing a task.
2. Task does SHTQ::process().

Another example:

1. SHTQ::process() start executing a task.
2. task does SHTQ::process().
2024-04-05 21:28:41 +02:00
Aliaksandr Kalenik
11011cf250 LibWeb: Don't rely on SHTQ::process() in process_the_iframe_attributes
`HTMLIFrameElement::inserted()` does following:
1. Init a new navigable. This step appends a task on session history
   traversal queue (SHTQ) that creates a new nested history.
2. Process iframe's attributes

Processing of iframe's attributes might result in synchronous
navigation that fails to get active SHE if SHTQ task that creates
new nested history is not yet completed.

Before this change, a workaround involved forcing the processing of
SHTQ, which was terrible hack because it could occur in the middle of
another SHTQ task.

This change removes the need for "force SHTQ processing" by ensuring
that the processing of iframe's attributes is always executed after
the iframe's navigable nested history has been created.
2024-04-05 21:28:41 +02:00
Aliaksandr Kalenik
8cc2ee34db LibWeb: Check if entryToReplace is contained in session history entries
This small hack will allow us to get rid of "force processing of
session history traversal queue" which is significantly more cumbersome
hack.
2024-04-05 21:28:41 +02:00
Aliaksandr Kalenik
adcc3905e5 LibWeb: Pass SynchronousNavigation flag into "apply the history step"
Workaround spec bug by explicitly carrying information whether
navigation is sync (History api, fragment change) or not.

See for more details https://github.com/whatwg/html/issues/10232
2024-04-05 21:28:41 +02:00
Andreas Kling
93ba99f14a LibWeb/WebAssembly: Add missing visit of WebAssembly::Memory::m_buffer 2024-04-05 16:22:54 +02:00
Shannon Booth
aab5d4e6f9 LibCore: Prevent SIGPIPE on Sockets by default
While this is the default for an underlying socket, it doesn't seem good
to have this as the default for our socket wrapper.

This fixes a crash in ladybird when connecting to the python HTTP server
with HTTPS.
2024-04-05 16:02:46 +02:00
Timothy Flynn
f3053f1d01 Ladybird/Qt: Add a "new tab" button to the Qt chrome
This adds a button on the right side of the location bar to create a new
tab.

Ideally, we would actually use QTabWidget::setCornerWidget to put this
button in the tab bar. But it is surprisingly difficult to make that
look nice on all platforms. Even if we ignore macOS, the CSS to make the
button look right on KDE Plasma may not work well on Gnome. So for now,
this location next to the location bar is horizontally the same that it
would be in the tab bar at least.
2024-04-05 15:27:29 +02:00
Timothy Flynn
795efea64f Ladybird/Qt: Close the browser when the last tab's close button is used
We currently do this already when the last tab is closed via the ctrl-W
shortcut. Move the logic for this to BrowserWindow::close_tab so that we
also close the window when the tab is closed via its close button.
2024-04-05 15:27:29 +02:00
Aliaksandr Kalenik
db31fa730a LibWeb: Increase completed jobs number even if navigable is destroyed
...otherwise spin_until() will stuck waiting.
2024-04-05 08:15:07 +02:00
Aliaksandr Kalenik
aefed21927 LibWeb: Add missing set_delaying_load_events(false) in navigate()
If navigation early returns before reaching "finalize a cross document
navigation" then we have to make sure delaying load events is disabled.

See spec issue https://github.com/whatwg/html/issues/10252
2024-04-05 08:15:07 +02:00
Andreas Kling
b2a099e647 LibWeb: Don't leak entire realm after parsing CSS @supports rule
Before this change, every CSS @supports rule would keep the containing
JS realm alive via a JS::Handle. This led to a GC reference cycle and
the whole realm leaked.

Since we only need the realm at construction time, we can take it as a
parameter instead, and stop storing it.
2024-04-05 08:14:19 +02:00
Andreas Kling
2ef37c0b06 LibWeb: Make EventLoop, TaskQueue, and Task GC-allocated
...and use HeapFunction instead of SafeFunction for task steps.

Since there is only one EventLoop per process, it lives as a global
handle in the VM custom data.

This makes it much easier to reason about lifetimes of tasks, task
steps, and random stuff captured by them.
2024-04-05 08:14:19 +02:00
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