Commit graph

17057 commits

Author SHA1 Message Date
Luke Wilde
da25ac0d48 AK: Treat empty string as invalid JSON
Previously we would treat the empty string as `null`. This caused
JavaScript like this to fail:
```js
var object = {};
try {
    object = JSON.parse("");
} catch {}
var array = object.array || [];
```
Since `JSON.parse("")` returned null instead of throwing, it would set
`object` to null and then try and use it instead of using the default
backup value.
2022-07-10 23:31:48 +02:00
Idan Horowitz
18d25124bf LibXML: Fail gracefully on integer overflow in character references
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47738
2022-07-10 22:29:11 +03:00
Karol Kosek
6901d3dcec LibGfx: Default-initialize dummy scanline
This should make the CI happier now.
2022-07-10 21:39:28 +03:00
gggggg-gggggg
d728017578 Kernel+LibC+LibCore: Pass fcntl extra argument as pointer-sized variable
The extra argument to fcntl is a pointer in the case of F_GETLK/F_SETLK
and we were pulling out a u32, leading to pointer truncation on x86_64.
Among other things, this fixes Assistant on x86_64 :^)
2022-07-10 20:09:11 +02:00
networkException
6697ab33dc LibGUI: Disallow selection identation in readonly text editors 2022-07-10 16:23:40 +02:00
Karol Kosek
b5420b8a9a LibGfx: Implement PNG filtering on write
Is it another great upgrade to our PNG encoder like in 9aafaec259?
Well, not really - it's not a 2x or 55x improvement like you saw there,
but still it saves something:

- a screenshot of a blank Serenity desktop dropped from about 45 KiB
  to 40 KiB.
- re-encoding NASA photo of the Earth to PNG again saves about 25%
  (16.5 MiB -> 12.3 MiB), compared to not using filters.

[1]: https://commons.wikimedia.org/wiki/File:The_Blue_Marble_(remastered).jpg
2022-07-10 15:01:07 +02:00
Karol Kosek
98a90d79de LibGfx: Move PNG header and paeth_predictor function to a shared header 2022-07-10 15:01:07 +02:00
Karol Kosek
ebc20f7ac3 LibGfx: Use enum instead of magic numbers for PNG Color and Filter types 2022-07-10 15:01:07 +02:00
Liav A
9dbec601b0 Kernel+SystemServer: Make KCOVDevice a character device
This device should not be a block device, as in Serenity, block devices
represent an interface to either disk partitions or storage devices.
2022-07-10 14:57:55 +02:00
Ali Mohammad Pur
d348eaf305 LibRegex: Treat inverted Compare entries as disjunctions
[^XYZ] is not(X | Y | Z), we used to translate this to
not(X) | not(Y) | not(Z), this commit makes LibRegex interpret this
pattern as not(X) & not(Y) & not(Z).
2022-07-10 14:26:03 +02:00
Ali Mohammad Pur
fe46b2c141 LibRegex: Correctly track current inversion state in the optimizer
This is currently not important as we do not nest TemporaryInverse.
2022-07-10 14:26:03 +02:00
Ali Mohammad Pur
9c5febe800 LibRegex: Flush compare tables before entering a permanent inverse state 2022-07-10 14:26:03 +02:00
Idan Horowitz
fbeef409c6 DynamicLoader: Stop performing relative relocations on non-pie objects
Co-authored-by: Daniel Bertalan <dani@danielbertalan.dev>
2022-07-10 14:24:34 +02:00
Karol Kosek
693d34fe3d LibCompress: Write Deflate window size in the Zlib header
Previously we said that the window size was always 512 bytes, which
caused errors during decompressing in apps outside of Serenity that
actually use this information.
Now, the value is always 7 (32 KiB).

Fixes: #14503
2022-07-10 13:52:18 +03:00
MacDue
72a37e5292 LibWeb: Tiebreak corner color on existence of corresponding borders
This fixes the blue border (that should be white/black -- depending
on the theme) between avatars on GitHub commits.
2022-07-10 12:46:57 +02:00
networkException
710fb11c73 LibGUI: Allow deleting text editor indent selections in non tab cases
Since 00f51d42d2aeb44ec4813ca13be787c2f5ca55ff we would not allow the
deletion for a selection by typing if it would match the conditions to
indent on pressing tab.

As any single line TextEditor would always match the indent conditions,
it was impossible to replace selected text by typing in a TextBox,
PasswordBox or UrlBox.

A missing return, as pointed out in https://github.com/SerenityOS/serenity/pull/13269#discussion_r900866416
was the cause for the additional checks in
TextEditor::insert_at_cursor_or_replace_selection, described in https://github.com/SerenityOS/serenity/pull/13269#discussion_r901009457
With the early return in place the additional checks are not aiding with
the indented behavior but cause the regression described above.

This patch removes the unnecessary conditions.
2022-07-10 12:20:02 +02:00
Linus Groh
071b92e920 LibJS: Fix typos in Temporal spec comments
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/b0411b4
2022-07-10 01:29:28 +02:00
Linus Groh
fb2012dfc7 LibJS: Add Add IsValidISODate assertions
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/46f97ea
2022-07-10 01:22:34 +02:00
Linus Groh
79fb149b36 js: Add missing built-in functions to help() output 2022-07-10 01:11:52 +02:00
Linus Groh
3c845b0ea4 js: Remove load() built-in function
This is no longer needed now that we have ES modules.
2022-07-10 01:11:52 +02:00
Andreas Kling
89e65e0ea1 LibWeb: Support flex item cross sizing based on intrinsic aspect ratio
This patch implements case B from the "determine the flex base size
and hypothetical main size of each item" from the flexbox algorithm.

https://drafts.csswg.org/css-flexbox-1/#algo-main-item
2022-07-10 00:47:46 +02:00
Andreas Kling
8eb022a57d LibWeb: Don't include flex line margins in inner flex item cross sizes
In cases where flex item cross size is based on the flex line cross
size, the spec specifically says to transfer the *outer* cross size of
the line. We were ignoring the "outer" part.

This patch fixes that by subtracting the cross margins from the size.
2022-07-10 00:04:41 +02:00
Andreas Kling
030dbfd2a9 LibWeb: Improve support for flex-start/end with reversed flex-direction
We now pass the "flex-direction" test from the CSSWG flexbox test suite.
2022-07-10 00:04:41 +02:00
Andreas Kling
cefc931347 LibWeb: Make sure CSS::ComputedValues has initial size values
Instead of using Optional<LengthPercentage>, we now use LengthPercentage
for these values. The initial values are all `auto`.

This avoids having to check `has_value()` in a ton of places.
2022-07-09 22:16:35 +02:00
Andreas Kling
734ff422ad LibWeb: Add LengthPercentage::is_auto() convenience helper
This lets you ask if a LengthPercentage is `auto` with one call instead
of two, which will make some conditions nicer to express.
2022-07-09 22:16:32 +02:00
Andreas Kling
44025e837f LibGfx: Use float when calculating text width in ScaledFont
This fixes an issue where we'd truncate the fractional part of each
glyph width, often making the returned width slightly too short.
2022-07-09 22:16:18 +02:00
Andreas Kling
80ed7d220c LibGfx: Paint whitespace characters (including &nbsp;) as empty space
This fixes an issue where &nbsp; would sometimes render as "A" in
web content.
2022-07-09 22:16:13 +02:00
Lucas CHOLLET
dab814ea11 LibCrypto: Add the [[nodiscard]] qualifier in both BigInteger classes 2022-07-09 15:55:32 +00:00
Lucas CHOLLET
6f04a3778b FileManager: Change PGID of spawned processes
Processes spawned by FileManager (e.g. through double-click) now set
their PGID to that of the session leader. It allows the filemanage
instance to be killed without propagating the signal to the new process.
2022-07-09 11:41:07 +01:00
MacDue
61a703816c LibWeb: Base marker size on font height rather than line height
This fixes the oversized markers on GitHub
2022-07-09 09:28:31 +01:00
kleines Filmröllchen
69218b92a5 LibCore+Userland: Use StringViews when calling Core::System::open
For some reason we used raw char pointers sometimes, which caused at
least one heap buffer overflow detected in fuzzing.
2022-07-09 09:25:20 +01:00
Maciej
7dd3c5c981 Applications: Add a new NetworkSettings application 2022-07-09 09:22:25 +01:00
Maciej
df7b7cbfa4 NetworkServer: Kill running DHCPServer before starting our own
We cannot run two DHCPServers at once, let's just kill the one that was
started previously.
2022-07-09 09:22:25 +01:00
Maciej
8526c3f680 NetworkServer: Clear default gateway route entry before adding 2022-07-09 09:22:25 +01:00
Maciej
20430ffeae route: Support removing entries with unknown gateway 2022-07-09 09:22:25 +01:00
Ali Mohammad Pur
b85666b3d2 LibRegex: Fix lookup table-based range checks in Compare
The lowercase version of a range is not required to be a valid range,
instead of casefolding the range and making it invalid, check twice with
both cases of the input character (which are the same as the input if
not insensitive).
This time includes an actual test :^)
2022-07-09 01:00:44 +00:00
Tim Schumacher
b9f7966e00 LibC: Move stack canary initialization before the global constructors
Once again, QEMU creates threads while running its constructors, which
is a recipe for disaster if we switch out the stack guard while that is
already running in the background.

To solve that, move initialization to our LibC initialization stage,
which is before any actual external initialization code runs.
2022-07-08 22:27:38 +00:00
Tim Schumacher
cf0ad3715e Kernel: Implement sigsuspend using a SignalBlocker
`sigsuspend` was previously implemented using a poll on an empty set of
file descriptors. However, this broke quite a few assumptions in
`SelectBlocker`, as it verifies at least one file descriptor to be
ready after waking up and as it relies on being notified by the file
descriptor.

A bare-bones `sigsuspend` may also be implemented by relying on any of
the `sigwait` functions, but as `sigsuspend` features several (currently
unimplemented) restrictions on how returns work, it is a syscall on its
own.
2022-07-08 22:27:38 +00:00
Tim Schumacher
5efa8e507b Kernel: Implement an axallowed mount option
Similar to `W^X` and `wxallowed`, this allows for anonymous executable
mappings.
2022-07-08 22:27:38 +00:00
Tim Schumacher
6187cf72cc LibM: Implement fma 2022-07-08 22:27:38 +00:00
Tim Schumacher
6c650d1b8d LibC: Add stubs for glob and globfree 2022-07-08 22:27:38 +00:00
Timothy Flynn
f672b4c151 LibUnicode: Remove now-unused Unicode::select_pattern_with_plurality 2022-07-08 20:33:52 +02:00
Timothy Flynn
5b68c1a06c LibJS: Use Intl.PluralRules within Intl.NumberFormat
This also allows removing a bit of a BigInt hack to resolve plurality of
BigInt numbers (because the AOs used in ResolvePlural support BigInt,
wherease the naive Unicode::select_pattern_with_plurality did not).

We use cardinal form here; the number format patterns in the CLDR align
with the cardinal form of the plural rules.
2022-07-08 20:33:52 +02:00
Timothy Flynn
6d9b779757 LibJS: Add an overload of ResolvePlural for use without PluralRules
The NumberFormat spec casually indicates the need for a PluralRules
object without explicity saying so, with text such as:

"which may depend on x in languages having different plural forms."

Other implementations actually do create a PluralRules object to resolve
those cases with ResolvePlural. However, ResolvePlural doesn't need much
from PluralRules to operate, so this can be abstracted out for use in
NumberFormat without the need to allocate a PluralRules instance.
2022-07-08 20:33:52 +02:00
Timothy Flynn
1fc87d1529 LibJS: Use Intl.PluralRules within Intl.DurationFormat 2022-07-08 20:33:52 +02:00
Timothy Flynn
232df4196b LibUnicode: Replace NumberFormat::Plurality with Unicode::PluralCategory
To prepare for using plural rules within number & duration format, this
removes the NumberFormat::Plurality enumeration.

This also adds PluralCategory::ExactlyZero & PluralCategory::ExactlyOne.
These are used in locales like French, where PluralCategory::One really
means any value from 0.00 to 1.99. PluralCategory::ExactlyOne means only
the value 1, as the name implies. These exact rules are not known by the
general plural rules, they are explicitly for number / currency format.
2022-07-08 20:33:52 +02:00
Timothy Flynn
cc5c707649 LibJS+LibUnicode: Do not generate the PluralCategory enum
The PluralCategory enum is currently generated for plural rules. Instead
of generating it, this moves the enum to the public LibUnicode header.
While it was nice to auto-discover these values, they are well defined
by TR-35, and we will need their values from within the number format
code generator (which can't rely on the plural rules generator having
run yet). Further, number format will require additional values in the
enum that plural rules doesn't know about.
2022-07-08 20:33:52 +02:00
huttongrabiel
9369610bf4 LibGUI: Unindent selected text on shift+tab press
Selected text is unindented when Shift+Tab is pressed. Select text,
indent it with Tab, then unindent with Shift+Tab.
2022-07-08 11:47:56 +01:00
huttongrabiel
2fbaa7996c LibGUI: Indent selected text on tab press
If selected text is less than a whole line, usual delete/replace takes
place. Otherwise, if the selected text is a whole line or spans
multiple lines, the selection will be indented.
2022-07-08 11:47:56 +01:00
Tim Schumacher
80705a72bd mount: Allow extending fstab via drop-in files in fstab.d 2022-07-08 12:42:23 +02:00