We had previous implemented some plumbing for file input elements in
commit 636602a54e.
This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
This makes it easier to work with device tree nodes and properties, then
writing simple state machines to parse the device tree.
This also makes the old slow traversal methods use the
DeviceTreeProperty helper class, and adds a simple test.
This adds a basic `mkfs.fat` utility, which can format FAT12, FAT16
and FAT32 partitions.
This does have a few limitations, namely in that FAT12 formatting is
limited to a set known floppy disk sizes, and we can only generate
512-byte sectors.
Previously, we would remove the "longest extension" from each file name
when parsing it as the name of a utility, which made it impossible for
the names of utilities to contain any extensions.
Before, TEST_MAIN used to return the return value of TestSuite::main()
function (which returns the number of test cases that did not pass, so
it can be >=256) directly.
The run-tests utility determines the success / failure of a test suite
binary by examining its (or i.e. TEST_MAIN's) exit status.
But as exit status values are supposed to be between 0 and 255, values
>=256 will get wrapped around (modulo 256), converting a return value of
256 to 0.
So, in a rare case where exactly 256 test cases are failing in your test
suite, run-tests utility will display that the test suite passed without
any failures.
Now, TEST_MAIN just returns 0 if all of the test cases pass and returns
1 otherwise.
The former automatically adapts the prefix to binary and octal
output, and is what we already use in the majority of cases.
Patch generated by:
rg -l '0x\{' | xargs sed -i '' -e 's/0x{:/{:#/'
I ran it 4 times (until it stopped changing things) since each
invocation only converted one instance per line.
No behavior change.
Before, we used to reject profiles where the creation datetime was
invalid per spec. But invalid dates happen in practice (most commonly,
all fields set to 0). They don't affect profile conversion at all,
so be lenient about this, in exchange for slightly more wordy code
in the places that want to show the creation datetime.
Fixes a crash rendering page 2 of
https://fredrikbk.com/publications/copy-and-patch.pdf
This allows the user to pass very specific values instead of a u64 value
that is later cast to the underlying type.
The change also adds support for passing v128 values:
- v(i64.const 4) (splat 4)
- v128.const 0x4 (just a few bits specificed, everything else = 0)
Previously, the check for `.html` meant that `.svg` tests were excluded.
This led to a few `.svg` with missing or bit-rotted expectations, which
have now been added/updated.
Before this change, the rebaseline script would generate reference
based on 'about:blank' (at least running it on my macOS system).
This commit allows 'about:blank' through the assertion and only dumps
the layout tree when theloaded URL matches the one we are interested
in.
Along with this, Port.h is include which helps generalising common
information for the port package, like it's name and version. With
SemVer complaint versions, it is possible to show positive change
(upgrade) or negative change (downgrade) in the installed ports.
However, for some non-complaint versions (eg. using git commit hash),
non-equality (`!=`) is used to notify upgrade. Since there is no
algorithm (without git history) to check the order of commits, it is
not possible to inform whether it is an upgrade or downgrade.
- Add interactive flag which tells `cp` to prompt before overwriting
files
- Accept 'yes', 'no', 'n', and 'y' as input, all other inputs will
result in the prompt being shown again
Instead of polluting global namespace with definitions from
libkern/OSByteOrder.h and machine/endian.h on MacOS, just use AK
functions for conversions.
This is useful for working with CMYK jpegs extracted from PDFs
by mutool. CMYK channels for jpegs in PDFs are inverted compared to
CMYK channels in standalone jpegs (!), and mutool doesn't compensate
for that.
You can now do:
mutool extract ~/Downloads/0000/0000711.pdf 461
Followed by:
Build/lagom/bin/image -o out.png \
--invert-cmyk \
--assign-color-profile \
Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
--convert-to-color-profile serenity-sRGB.icc \
cmyk.jpg
Doesn't exactly roll off the keyboard, but at least it's possible.
(We should probably add an implicit default CMYK color profile if
the input file doesn't have one, and assume conversion to sRGB when
saving to a format that can only store RGB.)
The IPC layer between chromes and LibWeb now understands that multiple
top level traversables can live in each WebContent process.
This largely mechanical change adds a billion page_id/page_index
arguments to make sure that pages that end up opening new WebViews
through mechanisms like window.open() still work properly with those
extra windows.
These were here due to the prefix-less name conflicting with a local
bool, but now that options are in a struct that's no longer a problem.
No behavior change.
`image` can't transform from RGB to CMYK yet, so the only way to
do this is by having a CMYK input.
For example, this works now (and it does a full decode and re-encode):
Build/lagom/bin/image -o out.jpg \
Tests/LibGfx/test-inputs/jpg/buggie-cmyk.jpg
Using this to convert `.pam` files written by `mutool extract`
to jpegs is a somewhat convenient method of looking at these
.pam files.
Previously `image -o foo.asdf foo.png` would create a 0-byte foo.asdf
before complaining that it doesn't know how to write .asdf images.
(Lifetimes of temporaries are extended to the end of the full
expresion, so this is fine.)
Previously, we ignored the -p argument if it was specified. This
would resort in a crash because final_target_directory wasn't given a
value.
This snapshot does away with giving this variable an Optional<> and
just has the -p argument be its default value.
We use these canonicalized_path variables as StringViews, so it doesn't
matter if they are a String or ByteString. And they're paths so
shouldn't be String anyway.
Every single of images's functions then go ahead and error out on
CMYKBitmaps for now.
(Alternatively, we could make them the low-quality CMYK->RGB
conversion that previously happened implicitly, but let's go
with this for now.)
(With this structure, we could also do something smarter for
Vector images in the future.)
Here's how this looks:
% Build/lagom/bin/image \
-o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
Runtime error: Can't save CMYK bitmaps yet, convert to RGB first
with --convert-to-color-profile
% Build/lagom/bin/image \
--convert-to-color-profile serenity-sRGB.icc \
-o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
Runtime error: No source color space embedded in image.
Pass one with --assign-color-profile.
% Build/lagom/bin/image \
--assign-color-profile path/to/CMYK/USWebCoatedSWOP.icc \
--convert-to-color-profile serenity-sRGB.icc \
-o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
Runtime error: Psych, can't convert CMYK bitmaps yet either
As usual, serenity-sRGB.icc is from
`Build/lagom/bin/icc -n sRGB --reencode-to serenity-sRGB.icc` and
the adobe cmyk profiles are available at
https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html
which ultimately leads to:
https://download.adobe.com/pub/adobe/iccprofiles/win/AdobeICCProfilesCS4Win_end-user.zip
This makes it easier to move the color space conversion code out
into a helper function, and will be used to pass around CMYK bitmaps.
No behavior change.
...instead of warn() + manual return.
Before:
% Build/lagom/bin/image -o out.asdf in.png
can only write .bmp, .png, .ppm, and .qoi
Now:
% Build/lagom/bin/image -o out.asdf in.png
Runtime error: can only write .bmp, .png, .ppm, and .qoi
That doesn't look worse, and it's less code (and makes moving the
code into helper functions easier).
The -p flag is equivalent to the previous behavior: outputting the
uptime in a human-readable form.
We don't seem to expose the number of online users or the load averages,
so those sections are missing from the output compared to those OSes.
We now split up symbols into zero-sized symbols that label single
instructions (no need to separate them by newlines; they are used for
jump labels and relocation targets within a larger block of code) and
ranged symbols that label functions. Empty symbols are discarded since
at least RISC-V ELF files contain quite a few of those. Zero-sized
symbols and ranged symbols are handled almost the same, but this way we
can make sure that zero-sized symbols don't interfere with ranged
symbol's newline separation logic. For zero-sized symbols, the "symbol
contains address" logic is updated so they actually contain the one
address they're pointing at, fixing the bug with many "dangling"
zero-sized symbols after a function that contained them. Zero-sized
labels are also no longer printed as a start-end range, since that is
unnecessary visual noise.
This is an option supported by coreutils, so we might as well support
it too.
It allows users to wrap their encoded output after the "column" value
they provide.
This commit also has the Markdown look more like what we see
when running ArgsParser::print_usage_markdown() (and it fixes some
of the examples).
This is to avoid duplicating the printing logic and so that we can
have an alternative way of printing the result (i.e. for the next
commit that will print without a pathname if no file operands were
provided). This also has us avoid the algorithm checks in the for
loop.
This creates a bitmap filled with a fixed color, then (in memory)
saves it as jpeg and loads it again, and repeats that until the
color of the bitmap no longer changes. It then reports how many
iterations that took, and what the final color was.
It does this for a couple of colors.
This is for quality assessment of the jpeg codec. Ideally, it should
converge quickly (in one iteration), and on a color not very far from
the original input color.
This utility uses the Core::DirIterator facility which in turn uses the
get_dir_entries syscall. Therefore, this utility lets us to view the
actual values for inode numbers, and entry type value for directory
entries.
`JsonValue::to_byte_string` has peculiar type-erasure semantics which is
not usually intended. Unfortunately, it also has a very stereotypical
name which does not warn about unexpected behavior. So let's prefix it
with `deprecated_` to make new code use `as_string` if it just wants to
get string value or `serialized<StringBuilder>` if it needs to do proper
serialization.
A bunch of users used consume_specific with a constant ByteString
literal, which can be replaced by an allocation-free StringView literal.
The generic consume_while overload gains a requires clause so that
consume_specific("abc") causes a more understandable and actionable
error.
These allow column-wise, traditional scanline, or random pixel flooding.
Depending on the use case and amount of contestion, any of the
strategies may work best, as tested on 37c3.
Very contested servers are likely to cause EAGAIN socket errors on the
client. Since these errors are not supposed to be fatal, just try
sending the pixel again.
This was tested successfully against massively contested 37c3 pixelflut
servers.
Instead of spawning these processes from the WebContent process, we now
create them in the Browser chrome.
Part 1/N of "all processes are owned by the chrome".
With this, we convert a bunch of random colors to a
profile's profile connection space and back, and count
how many u8 colors make it through unchanged.
With this, you can do something like:
for f in ~/Downloads/Adobe\ ICC\ Profiles\ \(end-user\)/*/*.icc; do
echo $f
Build/lagom/bin/icc --debug-roundtrip $f
done
to test conversion through a bunch of profiles. These profiles are
available at:
https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html
...which ultimately leads to:
https://download.adobe.com/pub/adobe/iccprofiles/win/AdobeICCProfilesCS4Win_end-user.zip
(Or use `Build/lagom/bin/icc --debug-roundtrip -n sRGB` to test the
built-in sRGB profile.)
These IPCs are different than other IPCs in that we can't just set up a
callback function to be invoked when WebContent sends us the screenshot
data. There are multiple places that would set that callback, and they
would step on each other's toes.
Instead, the screenshot APIs on ViewImplementation now return a Promise
which callers can interact with to receive the screenshot (or an error).
Instead of returning HeapBlock memory to the kernel (or a non-type
specific shared cache), we now keep a BlockAllocator per CellAllocator
and implement "deallocation" by basically informing the kernel that we
don't need the physical memory right now.
This is done with MADV_FREE or MADV_DONTNEED if available, but for other
platforms (including SerenityOS) we munmap and then re-mmap the memory
to achieve the same effect. It's definitely clunky, so I've added a
FIXME about implementing the madvise options on SerenityOS too.
The important outcome of this change is that GC types that use a
type-specific allocator become immune to use-after-free type confusion
attacks, since their virtual addresses will only ever be re-used for
the same exact type again and again.
Fixes#22274
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:
```
Optional<I> opt;
if constexpr (IsSigned<I>)
opt = view.to_int<I>();
else
opt = view.to_uint<I>();
```
For us.
The main goal here however is to have a single generic number conversion
API between all of the String classes.
While it would be more hygienic to get a fresh Navigable each time,
loading `about:blank` still means we discard the current Document.
This does noticeably increase the duration of running the LibWeb test
suite. On my machine, we go from ~5.5 seconds to ~7.7.
Before this change, it was possible for a text test to finish before
on_load_finish() was triggered, resulting in the subsequent test
receiving the load event from the previous test.
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).
This commit is auto-generated:
$ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
Meta Ports Ladybird Tests Kernel)
$ perl -pie 's/\bDeprecatedString\b/ByteString/g;
s/deprecated_string/byte_string/g' $xs
$ clang-format --style=file -i \
$(git diff --name-only | grep \.cpp\|\.h)
$ gn format $(git ls-files '*.gn' '*.gni')
It is currently a bit messy to pass these options along from main() to
where WebContent is actually launched. If a new flag were to be added,
there are a couple dozen files that need to be updated to pass that flag
along. With this change, the flag can just be added to the struct, set
in main(), and handled in launch_web_content_process().
We're seeing timeouts for WebWorker based tests in some CI runs. It's
possible that these are legitimate timeouts, so bump the default timeout
to 30sec. When porting the test runner to run on CI, Andreas had to bump
the test timeout from 5 seconds to 10, to 15. It's likely that loading
our ASAN/UBSAN binaries on slow CI machines takes a significant amount
of time. Tests that use the new WebWorker process are spawning yet
another process that needs to load LibWeb and all its dependencies.
When the `--dump-failed-ref-tests` flag is provided, screenshots of the
actual and reference pages will be placed in
`Build/lagom/ladbybird/test-dumps`. This makes it a lot easier to spot
what's wrong with a failing test. :^)
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.
We can now just unveil the /dev/beep device node, as well as to restrict
the utility functionality for rpath, wpath & stdio related syscalls only
because we don't actually need anything else.
There's no need to have separate syscall for this kind of functionality,
as we can just have a device node in /dev, called "beep", that allows
writing tone generation packets to emulate the same behavior.
In addition to that, we remove LibC sysbeep function, as this function
was never being used by any C program nor it was standardized in any
way.
Instead, we move the userspace implementation to LibCore.
Previously these handlers duplicated code and used formats that
were different from the one Error.prototype.stack uses.
Now they use the same Error::stack_string function, which accepts
a new parameter for compacting stack traces with repeating frames.
If we invoke the exit native function from within the exit builtin, the
native call will then invoke global destructors. This ultimately ends up
deleting the JS::NativeFunction that defines the exit builtin, thus we
try to delete the AK::Function held inside the NativeFunction while that
AK::Function is executing. This is explicitly forbidden by AK::Function.
Instead, simply set a flag to exit the REPL after the builtin executes.
This patch brings a service to handle image decompression. With it comes
security enhancement due to the process boundary. Indeed, consequences
of a potential attack is reduced as only the decoder will crash without
perturbing the WebContent process.
It also allows us to display pages containing images that we claim to
support but still make us crash, like for not-finished-yet decoders.
As an example, we can now load https://jpegxl.info/jxl-art.html without
crashing the WebContent process.
This makes the parser more resilient to invalid IMAP messages.
Usages of `Optional` have also been removed where the empty case is
equivalent to an empty object.
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>
Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
The POSIX specification for `find` says that: "Each path operand shall
be evaluated unaltered as it was provided, including all trailing
<slash> characters". This also matches the behavior of `find` on
FreeBSD and Linux.
These functions all have a very common case that can be dealt with a
very simple inline check, often avoiding the need to call an out-of-line
function. This patch moves the common case to inline functions in a new
ValueInlines.h header (necessary due to header dependency issues..)
8% speed-up on the entire Kraken benchmark :^)
As the newly created function has been also applied to printing the
number of matched file lines, file names will now also be colored
with the `--count` option set. :^)
Previously we had two somewhat duplicated methods: one just for handling
stdin with the standard C API, and the other one used for everything
else with our Core::File class. By using always Core::File, the code
should be now a little bit cleaner.
Additionally, grep will now use the standard input when it finds a '-'
argument (previously it tried to open a file with that name.)