Commit graph

55654 commits

Author SHA1 Message Date
tetektoza
d2995f7517 LibGUI: Add missing constructor to UISize class for fixed_size property
This patch adds a missing constructor to UISize class for fixed_size
property, so the property can take an array if user specified it
in .gml file.
2023-10-24 21:47:18 +02:00
Nico Weber
e7f7c434f7 LibPDF: Don't check for startxref after trailer dict
Several files have a comment after the trailer dict and the
`startxref` after it.

We really should add a consume_whitespace_and_comments() function
and call that in most places we currently call consume_whitespace().

But in this case, for non-linearized files, we first jump to the
end of the file, read `startxref`, then jump to `xref` from the
offset there, and then read the trailer after the `xref`,
only to read `startxref` again. So we can just not do that.

(For linearized files, we now completely ignore `startxref`.
But we don't use the data in `startxref` in linearized files
anyways, so it's fine to not read it there too.)

Reduces number of crashes on 300 random PDFs from the web (the first 300
from 0000.zip from
https://pdfa.org/new-large-scale-pdf-corpus-now-publicly-available/)
from 25 (8%) to 23 (7%).
2023-10-24 13:32:01 -04:00
Nico Weber
acf668e234 LibPDF: Make Reader::move_by() parameter more truthful
No behavior change, just simpler and less surprising.
2023-10-24 13:30:25 -04:00
Aliaksandr Kalenik
b13ff8def6 LibWeb: Separate "out of view" check from RecordingPainter commands 2023-10-24 18:55:12 +02:00
Aliaksandr Kalenik
94f322867a LibWeb: Get rid of DevicePixels usage in RecordingPainter
This change removes inconsistency in coordinate representation of
painter commands by changing everything to use int.
2023-10-24 18:55:12 +02:00
Tim Schumacher
b91d03c2b8 Meta: Don't pass ^C through the serial console on CI
`-serial mon:stdio` passes through all kinds of key combinations,
`-serial stdio` doesn't. This probably isn't something that we want
while running tests or CI, so switch to the non-passing variant.

aarch64 actually failed to run due to this, since it already had
`-serial stdio` in its arguments, causing a conflict. This is why that
entry is now gone entirely.
2023-10-24 13:45:55 +02:00
Tim Ledbetter
fff1645c6b Fuzzers: Add WOFF2 fuzzer 2023-10-24 13:45:01 +02:00
Tim Ledbetter
e9be1bcd09 LibGfx/WOFF2: Reject fonts with a compressed size larger than 10MiB
This prevents a potential OOM condition when the header is malformed.
2023-10-24 13:45:01 +02:00
Tim Ledbetter
af633523af LibGfx/WOFF2: Tolerate incorrect totalSfntSize in WOFF2 header
The specification says that this value is for reference only, so we
should be able to load a file where this value is incorrect.
2023-10-24 13:45:01 +02:00
Timothy Flynn
0eaf13bae3 AK: Colorize log message for failed assertions
The log message can be hard to spot in a sea of debug messages. Colorize
it to make the message more immediately pop out.
2023-10-24 06:58:53 -04:00
Tim Schumacher
acc0fb7a47 Meta: Manually redirect CI serial output to stdout
`-nographic` additionally reconfigures the Terminal, which clears the
previous scrollback and (ocasionally) breaks line wrapping. This is
probably not something that we want, so only ask for the redirection
behavior.
2023-10-24 11:27:20 +02:00
Tim Ledbetter
03fbd6c0c8 Fuzzers: Add a fuzzer for JsonParser 2023-10-24 07:54:37 +02:00
Andrew Duerig
67ca5d6572 Meta: Update libjs.dev links to test262.fyi 2023-10-24 07:32:19 +02:00
Tim Ledbetter
cb16c217b8 Tests: Add regression tests for fixed OSS-Fuzz test cases 2023-10-24 07:30:04 +02:00
Tim Ledbetter
c62dded5cc Tests: Move image decoder test PNG to its own folder 2023-10-24 07:30:04 +02:00
Tim Ledbetter
c2112cde76 LibGfx/WOFF: Ensure header totalSfntSize matches expected value 2023-10-24 07:29:09 +02:00
Tim Ledbetter
7ee09ca49d LibGfx/WOFF: Avoid overflow in table directory search range
This commit limits `WOFF::Header::num_tables` to 4096. This limitation
is not explicitly mentioned in the specification, but allowing numbers
larger than this results in an overflow when calculating
`search_range` and `range_shift`.
2023-10-24 07:29:09 +02:00
Timothy Flynn
4c479b0aaa Ladybird/AppKit: Add a context menu item to search for the selected text 2023-10-24 07:28:30 +02:00
Timothy Flynn
66c8400384 Ladybird/Qt: Add a context menu item to search for the selected text 2023-10-24 07:28:30 +02:00
Timothy Flynn
ae6e2e682e Browser: Add a context menu item to search for the selected text 2023-10-24 07:28:30 +02:00
Timothy Flynn
6af279a22d LibWebView: Add a helper to get selected text with collapsed whitespace 2023-10-24 07:28:30 +02:00
Timothy Flynn
e221b3afeb LibWebView: Add an API to format a search query for UI display
This will create a string of the form:

    Search DuckDuckGo for "Ladybird is awesome!"

If the provided query URL is unknown, the engine name is excluded (e.g.
for custom search URLs).
2023-10-24 07:28:30 +02:00
Timothy Flynn
c8c3d00615 LibWebView: Rename find_search_engine to find_search_engine_by_name
We will also need to search by URL in the Serenity chrome.
2023-10-24 07:28:30 +02:00
Bastiaan van der Plaat
d5ca8209bf LibWeb: Add input element valueAsNumber 2023-10-24 07:27:14 +02:00
Bastiaan van der Plaat
d290569535 LibWeb: Don't create shadow root for input hidden 2023-10-24 07:27:14 +02:00
Bastiaan van der Plaat
3e778fe29c LibWeb: Reorder and add missing form elements IDL items 2023-10-24 07:27:14 +02:00
Aliaksandr Kalenik
4dab17427f LibWeb: Use max content contribution in flex_fraction in GFC
As spec comment in the code says we should use item’s max-content
contribution to calculate flex fraction.

Likely, it was calculate_max_content_size() because we didn't have
calculate_max_content_contribution() when this function was implemented
initially.
2023-10-24 07:26:25 +02:00
Aliaksandr Kalenik
802b58d7e1 LibWeb: Resolve grid item's min-width and max-width in GFC
Now min-width and max-width properties affect resulting width of grid
item instead of being ignored.
2023-10-24 07:25:20 +02:00
Tim Ledbetter
db929e0fcf Kernel/Ext2: Avoid overflow when updating UID and GID values
Previously, attempting to update an ext2 inode with a UID or GID
larger than 65535 would overflow. We now write the high bits of UIDs
and GIDs to the same place that Linux does within the `osd2` struct.
2023-10-24 07:21:11 +02:00
Adrian Mück
7e10f76021 LibGUI: Don't update ComboBox text when model index is invalid
Without ENABLE_TIME_ZONE_DATA the user is able to update the time zone
selection when using "on_mousewheel" or "on_{up,down}_pressed" even
though UTC is supposed to be the only option. Due to an invalid model
index, the selection is set to "[null]".

Prior to this patch, the ComboBox text in "selection_updated" is set
at each call.
2023-10-23 21:18:36 -04:00
Andrew Kaster
3b733ff7bc WPT: Update metadata for current WPT master and ladybird results 2023-10-24 01:43:31 +02:00
Andrew Kaster
5a334ae958 WPT: Update to latest master and remove unnecessary patch 2023-10-24 01:43:31 +02:00
Andrew Kaster
4522c82459 Meta: Add gn build for the MacPDF application 2023-10-23 15:25:24 -06:00
Andrew Kaster
967ccd2be8 Meta: Add gn build for LibPDF 2023-10-23 15:25:24 -06:00
Andrew Kaster
10298f1e9a Meta: Move invoke_process_with_args.py to common location
This script was already used by both Ladybird and the Kernel, so move it
into Meta/gn/build instead.
2023-10-23 15:25:24 -06:00
Timothy Flynn
00826b2512 BrowserSettings: Use index column when casting to a search engine field
Regressed in e8d921820a.

I must've run an old version of the Serenity image when I tested this
after a fixup.
2023-10-23 13:36:48 -04:00
Nico Weber
3fe9f8e48d LibPDF: Don't accidentally form new tokens on pages with contents arrays
A page's /Contents can be an array of streams, and the page's contents
are then as if those streams are concatenated.

Most of the time, a stream ends with whitespace. But in some cases
(e.g. 0000642.pdf from 0000.zip from the pdfa dataset), the first
stream ends with an operator (`Q`) and the next stream starts with
one (`q`), and the concatenation would form a new, unkonwn operator
(`Qq`). Separate the streams' contents with a space to prevent that.

Reduces numbers of PDF files we fail to open in the -n 500 case
from 11 to 10 (in either case, we then crash on 18 of the PDFs
that we do manage to open).
2023-10-23 13:23:54 -04:00
Timothy Flynn
f885839ba5 Ladybird/AppKit: Support searching with a search engine in the URL bar
The setting for the search engine to use is currently ephemeral. Once we
have a settings dialog, we can implement this setting there, and persist
that setting.
2023-10-23 12:12:36 -04:00
Timothy Flynn
e7d977f58d Ladybird/Qt: Display drown-down settings using QPushButton
The default behavior of QPushButton is much closer to what we want from
a drop-down menu, as shown in the QPushButton::setMenu documentation:
https://doc.qt.io/qt-6/qpushbutton.html#setMenu

This also results in much less of a "squished" look than before.
2023-10-23 12:12:36 -04:00
Timothy Flynn
63577e8d1c Ladybird/Qt: Increase default size of the settings dialog
The current size is too small to be able to read the new tab URL. Use
the `resize` API rather than setting a fixed-size as well, to allow the
user to resize the dialog themselves.
2023-10-23 12:12:36 -04:00
Timothy Flynn
f8f0c5459d Ladybird/Qt: Migrate to LibWebView for search engines 2023-10-23 12:12:36 -04:00
Timothy Flynn
e8d921820a Browser+BrowserSettings: Migrate to LibWebView for search engines 2023-10-23 12:12:36 -04:00
Timothy Flynn
b770ed03ac LibWebView: Define the list of built-in search engines in LibWebView
These engines and their query URLs are duplicated in several places.
Before implementing search support in the AppKit chrome, let's move
these engines to LibWebView.
2023-10-23 12:12:36 -04:00
hanaa12G
10428fc7ce Solitaire: Port to GML compilation 2023-10-23 16:13:05 +01:00
Nico Weber
df0dd26ce2 Meta: Make test_pdf.py not count regular "failed to open" as crash
Some files just aren't valid PDF files that e.g. Preview.app can't
open either. Let's not count those (exit code 1) as crashes.
2023-10-23 09:33:39 -04:00
Nico Weber
11bee7a075 LibPDF: Don't crash on fixed-width type 1 fonts that use /MissingWidth
Type 1 fonts usually have a m_font_program and no m_font -- they only
have m_font if we're using a replacement font for the fonts that
were built-in to PDFs before Acrobat 4.0 (and must still work to
show existing files).

However, SimpleFont::get_glyph_width() used to always return a
float, which in Type1Font was only implemented if m_font was set.

Per spec, we're supposed to just use /MissingWidth for fonts that
are missing an entry in the descriptor's /Width array. However, for
built-in fonts, no explicit /Width array is needed (PDF 1.7 spec,
Appendix H.3, 5.5.1). So if we just always use /MissingWidth,
then PDFs that use a built-in font draw all their text on top
of each other (e.g. 000333.pdf from stillhq.com-pdfdb).

So change get_glyph_width() to return Optional<float>, return
it only in Type1Font if m_font is set, and use MissingWidth
if it isn't set.

That way, replacement fonts still return a width, and real
fonts that are supposed to have /Width and use /MissingWidth
for missing entries do what they're supposed to too, instead
of crashing.

From 20 (6%) to 16 (5%) crashes on the 300 first PDFs, and from
39 (7.8%) to 31 (6.2%) on the 500-random PDFs test.
2023-10-23 09:33:03 -04:00
Nico Weber
52afa936c4 LibPDF: Don't over-read in charset formats 1 and 2
`left` might be a number bigger than there are actually glyphs in the
CFF.

The spec says "The number of ranges is not explicitly specified in the
font. Instead, software utilizing this data simply processes ranges
until all glyphs in the font are covered." Apparently we have to check
for this within each range as well.

Needed for example in 0000054.pdf and 0000354.pdf in 0000.zip in the
pdfa dataset.

Together with the previous commit:

From 21 (7%) to 20 (6%) crashes on the 300 first PDFs, and from
41 (8.2%) to 39 (7.8%) on the 500-random PDFs test.
2023-10-23 09:31:11 -04:00
Nico Weber
58ff7b5336 LibPDF: Support offset size 3 in CFF index reading
...and replace template instantiations with a loop, to make this
easily possible.

Vaguely nice for code size as well.

Needed for example in 0000054.pdf and 0000354.pdf in 0000.zip in the
pdfa dataset.
2023-10-23 09:31:11 -04:00
Nico Weber
3197f0cab6 LibPDF: Handle CFF fonts with charset format 0 and > 255 glyphs better
We used to use an u8 as loop counter, which would overflow
if there were more than 255 glyphs, producing hundreds of megabytes
of

    Couldn't find string for SID x, going with space

output in the process, while all data until the end of the CFF
section got interpreted as SIDs, until a try_read() would finally
fail.

We now no longer fail miserably trying to render page 2 of
0000352.pdf of 0000.zip from the pdfa dataset.

Fixes just one crash of the larger 500-document test set, but
when I tweak test_pdf.py to print all stacks instead of just the
top 5, it no longer produces 260 MB of output.
2023-10-23 09:31:11 -04:00
Nico Weber
0869ca5615 LibPDF: Add more CFF_DEBUG output 2023-10-23 09:31:11 -04:00