Commit graph

52225 commits

Author SHA1 Message Date
Nico Weber
2061ee2632 Tests/LibPDF: Add test for AES-encrypted PDF
I created this by typing "sup" into TextEdit.app on macOS 13.4,
hitting Cmd-P to bring up the print dialog, clicked the PDF button
at the bottom, changed Title and Author to "sup", clicked
"Security Options…", and checked "Require password to open document"
(with password "sup").

This file tests several things:
- It has a compressed stream as first object. This used to make the
  linearization dict detection logic assert.
- It uses AES as encryption key using version 4 of the encryption
  dict. This used to not be implemented.
2023-07-12 06:28:15 +02:00
Nico Weber
e0887dd045 Tests/LibPDF: Use MUST() more
No behavior change.
2023-07-12 06:28:15 +02:00
Nico Weber
5998072f15 LibPDF: Add support for AESV2 encryption 2023-07-12 06:28:15 +02:00
Nico Weber
67d8c8badb LibPDF: Use more direct method to access linearization dict
We know indirect_value_or_error.value contains an IndirectObject,
so there's no need to go through resolve().

No behavior change.
2023-07-12 06:28:15 +02:00
Nico Weber
39b2eed3f6 LibPDF: Do not crash on encrypted files that start unluckily
PDF files can be linearized. In that case, they start with a
"linearization dict" that stores the key `/Linearized` and the value
`1`. To check if a file is linearized, we just read the first dict, and
then checked if it has that key.

If the first object of a PDF was a stream with a compression filter
and the input PDF was encrypted and not linearized, then us trying to
decode the linearization dict could crash due to stream contents being
encrypted, decryption state not yet being initialized, and us trying
to decompress stream data before decrypting it.

To prevent this, disable uncompression when parsing the first object
to determine if it's a lineralization dictionary.

(A linearization dict never stores string values, so decryption
not yet being initialized is not a problem. Integer values aren't
encrypted in encrypted PDF files.)
2023-07-12 06:28:15 +02:00
Nico Weber
c781686198 pdf: Add a --password option for encrypted PDFs 2023-07-12 06:28:15 +02:00
Nico Weber
63670f27de LibPDF: Rename m_disable_encryption to m_enable_encryption
Double negation is confusing.

No behavior change.
2023-07-12 06:28:15 +02:00
Nico Weber
92d2895057 LibPDF: Remove a pointless template specialization
We can just have two functions with actual names instead of specializing
on a bool template parameter.

No behavior change.
2023-07-12 06:28:15 +02:00
Xexxa
deb0c53779 Base: Add more emoji
🧎🏻 - U+1F9CE U+1F3FB PERSON KNEELING: LIGHT SKIN TONE
🧎🏼 - U+1F9CE U+1F3FC PERSON KNEELING: MEDIUM-LIGHT SKIN TONE
🧎🏽 - U+1F9CE U+1F3FD PERSON KNEELING: MEDIUM SKIN TONE
🧎🏾 - U+1F9CE U+1F3FE PERSON KNEELING: MEDIUM-DARK SKIN TONE
🧎🏿 - U+1F9CE U+1F3FF PERSON KNEELING: DARK SKIN TONE
🧎🏻‍♂️ - U+1F9CE U+1F3FB U+200D U+2642
MAN KNEELING: LIGHT SKIN TONE
🧎🏼‍♂️ - U+1F9CE U+1F3FC U+200D U+2642
MAN KNEELING: MEDIUM-LIGHT SKIN TONE
🧎🏽‍♂️ - U+1F9CE U+1F3FD U+200D U+2642
MAN KNEELING: MEDIUM SKIN TONE
🧎🏾‍♂️ - U+1F9CE U+1F3FE U+200D U+2642
MAN KNEELING: MEDIUM-DARK SKIN TONE
🧎🏿‍♂️ - U+1F9CE U+1F3FF U+200D U+2642
MAN KNEELING: DARK SKIN TONE
🧎🏻‍♀️ - U+1F9CE U+1F3FB U+200D U+2640
WOMAN KNEELING: LIGHT SKIN TONE
🧎🏼‍♀️ - U+1F9CE U+1F3FC U+200D U+2640
WOMAN KNEELING: MEDIUM-LIGHT SKIN TONE
🧎🏽‍♀️ - U+1F9CE U+1F3FD U+200D U+2640
WOMAN KNEELING: MEDIUM SKIN TONE
🧎🏾‍♀️ - U+1F9CE U+1F3FE U+200D U+2640
WOMAN KNEELING: MEDIUM-DARK SKIN TONE
🧎🏿‍♀️ - U+1F9CE U+1F3FF U+200D U+2640
WOMAN KNEELING: DARK SKIN TONE
🦫 - U+1F9AB BEAVER
2023-07-12 06:26:21 +02:00
Peter Elliott
da96c151ab LibCore: Exit EventLoop::spin_until() when exit requested
This keeps WebContent from staying open if it's spinning forever trying
to load a page.
2023-07-12 05:51:00 +02:00
Linus Groh
dc5d85b609 LibJS: Unwrap correct completion in group_by() 2023-07-12 00:34:01 +02:00
Linus Groh
419e710c1c LibJS: Re-implement the Array Grouping proposal as static methods
Closes #19495.
2023-07-12 00:03:54 +02:00
Nico Weber
f418605ec7 pdf: Print PDF version; tweak output 2023-07-11 13:49:17 -04:00
Nico Weber
ea89053c12 LibPDF: Make PDF version accessible on Document 2023-07-11 13:49:17 -04:00
Andreas Kling
9174ffd7e6 LibWeb: Create Layout::Box for display: inline-grid
This makes us actually run a GridFormattingContext instead of rendering
inline-grid elements as nothing. :^)
2023-07-11 19:15:17 +02:00
Valtteri Koskivuori
5615ea5386 LibCore: Replace non-breaking hyphens with regular ones in MimeData
These three lines were added in commits 41d5531, 0f7a651 and 97aca8f all
the way back in June 2020, and went unnoticed until Lucas pointed this
out during my refactoring.
2023-07-11 17:48:57 +01:00
Valtteri Koskivuori
f2ce47e3a1 Userland: Sync file utility descriptions with LibCore
Added descriptions for the following formats: icc, bzip2, SerenityOS
Spreadsheet, svg, tiff, targa, css, csv, html, plaintext, webm
2023-07-11 17:48:57 +01:00
Valtteri Koskivuori
ff83b909f0 LibCore: Sort and tidy up filename mime guess function
These too should be sorted alphabetically, as evidenced by the fact that
text/markdown was in there twice before this change. :^)
Also broke out tables of sufffixes and basenames we consider plaintext,
and sorted those alphabetically as well.
2023-07-11 17:48:57 +01:00
Valtteri Koskivuori
21473ea7f1 LibCore: Improve mime type enumeration sorting
It makes far more sense to sort by the standard mime type strings,
rather than the ad-hoc variable names associated with each enumeration.
This way, the sort looks nicer, and also matches the corresponding
description enumerations in the file utility.
2023-07-11 17:48:57 +01:00
Valtteri Koskivuori
2c6b156803 Userland: Teach the file utility about zip files
It now shows a short description with a file and directory counts, and
the total content size uncompressed.
2023-07-11 17:48:57 +01:00
Karol Kosek
729aae8437 Ladybird: Allow loading 'data:' URLs from a search bar 2023-07-11 15:30:11 +02:00
Lucas CHOLLET
9ff706339b LibGfx/PortableFormat: Read the header during initialization
This is done as a part of #19893.
2023-07-11 14:16:33 +01:00
Lucas CHOLLET
f3ff9c26bc LibGfx/PortableFormat: Simplify the State enum
This enum used to store very precise state about the decoding process,
let's simplify that by only including two steps: HeaderDecoder and
BitmapDecoded.
2023-07-11 14:16:33 +01:00
Lucas CHOLLET
f6ce06d56b LibGfx/PortableFormat: Extract header reading in its own function 2023-07-11 14:16:33 +01:00
Lucas CHOLLET
e72293fbc7 LibGfx/PortableFormat: Remove PortableImageDecoderPlugin::initialize() 2023-07-11 14:16:33 +01:00
Nico Weber
f7f9f1f47f LibGfx/PNG: Make invalid sRGB chunk size non-fatal
https://www.haiku-os.org/images/bg-page.png has a size of 0 for
example.

Just ignoring the chunk instead of assuming that the image is sRGB
and has Perceptual rendering intent matches what libpng does
(cf `png_handle_sRGB()`), so let's do that too.

(All other chunk handlers are still strict about size.)
2023-07-11 15:07:42 +02:00
Jelle Raaijmakers
3b2a7135b2 Ports: Add archive hash to Quake port
Also update the code style.
2023-07-11 13:42:02 +01:00
Andi Gallo
a27c9d8b05 LibWeb: Use max width from content for cells unless length is specified
Max width shouldn't be tied to min width, commit d33b99d went too far
and made them the same when the table-root had a specified percentage
width.

Fixes #19940.
2023-07-11 14:37:30 +02:00
Tim Ledbetter
4e7e878606 ps: Add --ppid option to filter by parent PID 2023-07-11 13:02:08 +01:00
Tim Ledbetter
d3c5ae0860 ps: Add -t option to filter by TTY 2023-07-11 13:02:08 +01:00
Tim Ledbetter
aeb87d6e78 ps: Allow multiple filtering options to be used simultaneously
Previously, it was assumed that only one filtering option, such as
`-u` or `-p` would be used at a time. With this PR, processes are now
shown if they match any of the specified filters.
2023-07-11 13:02:08 +01:00
Tim Ledbetter
a758e27153 ps: Disallow using -q with any other filtering options
This matches the behavior of `ps` on Linux.
2023-07-11 13:02:08 +01:00
Andreas Kling
5e24b97275 LibWeb: Implement HTMLImageElement.complete according to spec
Now that we use the HTML image loading algorithm from spec, we can
implement complete correctly.

This (finally) fixes an issue where images were not loading on
https://twinings.co.uk/ :^)
2023-07-11 10:03:49 +02:00
Andreas Kling
92bc3d200d LibWeb: Fix incorrectly offset root intersection rectangle for Document
When the intersection root is a Document, we use the viewport itself as
the root intersection rectangle. However, we should only use the size of
the viewport and strip away the current scroll offset.

This is important, as intersections are computed using viewport-relative
element rects, so we're already in a coordinate system where (0, 0) is
the top left of the scrolled viewport.

This fixes an issue where IntersectionObservers would fire at entirely
wrong scroll offsets. :^)
2023-07-11 10:03:49 +02:00
Kirill Nikolaev
6cdb1f0415 Kernel: Add an initial implementation of virtio-net driver
It can be exercised by setting
    SERENITY_ETHERNET_DEVICE_TYPE=virtio-net-pci.
2023-07-11 00:49:11 -06:00
Ali Mohammad Pur
b00a23b0b6 LibWeb: Fix a spec link in CSS/Parser
This pointed to the wrong part of the spec, make it point to the right
part instead :P
2023-07-11 09:38:37 +03:30
Ali Mohammad Pur
d60d149e62 LibWeb: Move some static functions from CSS/Parser.cpp into a new file 2023-07-11 09:38:37 +03:30
Ali Mohammad Pur
06c6c40df9 LibWeb+LibJS: Move some code around to make CSS/Parser parse faster
This makes it possible to include fewer full definitions of things,
which makes the file about 30% faster to compile.
2023-07-11 09:38:37 +03:30
Ali Mohammad Pur
392b5c3b19 LibJS: Resolve a circular include problem between HeapBlock and Cell
Cell::heap() and Cell::vm() needed to access member functions from
HeapBlock, and wanted to be inline, so they were moved to VM.h.
That approach will no longer work with VM.h not being included in every
file (starting from the next commit), so this commit fixes that circular
import issue by introducing secondary base classes to host the
references to Heap and VM, respectively.
2023-07-11 09:38:37 +03:30
Aliaksandr Kalenik
41f9dcd89b LibWeb: Implement "create a new child navigable" and supporting code
Implements https://html.spec.whatwg.org/multipage/document-sequences.html#create-a-new-child-navigable

Co-authored-by: Andreas Kling <kling@serenityos.org>
2023-07-11 06:48:25 +02:00
Taj Morton
1d2f1abf97 FileSystem/FATFS: Convert internal FAT inode attributes to dirent types 2023-07-10 21:54:23 -06:00
Beckett Normington
a961447dbd Ports: Add jdupes port
This commit ports the file deduplication utility `jdupes`.
2023-07-10 21:49:53 -06:00
Beckett Normington
73b5e3db6a Ports: Add libjodycode port
This commit ports `libjodycode` to Serenity, which is a helper library
containing shared code for utilities written by Jody Bruchon. This
library was required for porting `jdupes`.
2023-07-10 21:49:53 -06:00
Tim Schumacher
9d6372ff07 Kernel: Consolidate finding the ELF stack size with validation
Previously, we started parsing the ELF file again in a completely
different place, and without the partial mapping that we do while
validating.

Instead of doing manual parsing in two places, just capture the
requested stack size right after we validated it.
2023-07-10 21:08:31 -06:00
Lucas CHOLLET
398f7ae988 AK: Move chunks a single time in cleanup_unused_chunks()
All elements of the vector were moved to the left, for each element to
remove. This patch makes the function move each element exactly once.

On the same test case as the previous commit, it makes the function
disappear from the profile. These two commits combined reduce the
decompression time by 12%.
2023-07-10 21:35:10 -04:00
Lucas CHOLLET
44bedf7844 AK: Don't reuse chunks in AllocatingMemoryStream
As confusing as it may sound, reusing them is terrible performance wise.
When profiling the PNG decoder, the result (which is dominated by the
Zlib decompression) shows that the `cleanup_unused_chunks()` function
represented 14.26% of the profile before this patch and only 7.7%
afterward.

On a 6.5 MB PNG image, it reduces the decompression time by more than
5%.
2023-07-10 21:35:10 -04:00
Xexxa
d2637d54e5 Base: Add more emoji
🐏 - U+1F40F RAM
🐦‍⬛ - U+1F426 U+200D U+2B1B BLACK BIRD
📟 - U+1F4DF PAGER
🚻 - U+1F6BB RESTROOM
🚼 - U+1F6BC BABY SYMBOL
2023-07-10 19:47:19 -04:00
Andreas Kling
06d9451551 LibWeb: Don't cache property accesses on WindowProxy
Since the underlying HTML::Window can change, caching property accesses
on WindowProxy is not as simple as remembering the shape. Let's disable
caching here for now. We can come back to it in the future when we have
no low-hanging fruit left. :^)

Fixes an assertion failure on https://twinings.co.uk/
2023-07-11 00:14:50 +02:00
Andreas Kling
cf6792ec40 LibJS/Bytecode: Invalidate inline caches on unique shape mutation
Since we can't rely on shape identity (i.e its pointer address) for
unique shapes, give them a serial number that increments whenever a
mutation occurs.

Inline caches can then compare this serial number against what they
have seen before.
2023-07-11 00:14:50 +02:00
Sebastian Zaha
17d23e76e5 LibWeb: Fix flex & abspos alignment issues
Fixes a couple of weirder interactions between justify-content and
flex-direction related to reverse direction packing and how margins
are set.
2023-07-10 20:57:49 +02:00