Commit graph

5158 commits

Author SHA1 Message Date
AnotherTest
8cada744df LibRegex: Give the bytecode a chance to run when there's no input
Fixes #4246
Also adds a test case.
2020-11-30 11:37:30 +01:00
AnotherTest
ab2c646d5d LibRegex: Fix OOB access in Regex debug print 2020-11-30 11:37:30 +01:00
Linus Groh
ea08bf5812 LibJS: Fix crash in Lexer on EOF in unterminated template literal
Fixes #4252.
2020-11-30 11:36:42 +01:00
Linus Groh
8284f87867 LibRegex: Add bounds check to Lexer::back()
If the offset is zero and we're already at the end of the lexer's input
an out of bounds read (m_source[m_position]) would occur.
Also check that the offset is not more than m_position (which should
never be the case, and would result in m_position underflowing).

Fixes #4253.
2020-11-30 11:36:24 +01:00
Luke
7094697743 LibMarkdown: Reduce debug spam from invalid characters in table headings
Happens a lot when fuzzing.
2020-11-30 11:35:45 +01:00
Andreas Kling
65eef944ab LibWeb: Auto-size table box height to fit all the rows
This is just a hack until we implement the full 'height' property for
tables. :^)
2020-11-29 22:39:01 +01:00
Andreas Kling
b19f62217f LibWeb: Allow inline-block boxes to have non-inline children
We were incorrectly hoisting non-inline children of inline-block boxes
to the nearest non-inline ancestor.

Since inline-block boxes are only inline on the *outside*, it's fine
for them to have non-inline children.

Eventually we should clarify these relationships by making the inside
and outside display types more explicit.
2020-11-29 22:26:54 +01:00
Andreas Kling
13c32e0607 LibCore: Reduce debug spam from successful gzip decoding 2020-11-29 22:20:27 +01:00
Andreas Kling
39c7d9f061 LibWeb: Remove margin/border/padding from inline-block available width 2020-11-29 22:00:44 +01:00
Nico Weber
34c5478f31 LibGfx: Validate bit depths, and don't assert on invalid color type
The PNG spec says that each color type only allows certain bit depths,
so add explicit checks for that.
2020-11-29 21:28:44 +01:00
Nico Weber
fe999d6281 LibGfx: Make PNGLoader not assert on images with missing chunks
Before this, images without IHDR, or palettized images with no or
too small PLTE would lead to asserts. Found by running FuzzPNGLoader
locally.
2020-11-29 21:28:44 +01:00
Nico Weber
7db765bb73 LibGfx: Put debug output in PNGLoader behind PNG_DEBUG 2020-11-29 21:28:44 +01:00
Andreas Kling
d0636291fe LibWeb: Resolve percentage width/height of inline-block boxes
Percentage lengths cannot be to_px()'ed directly, we have to resolve
them against a reference (the containing block) first.

Fixes #4248.
2020-11-29 21:27:41 +01:00
Linus Groh
eea7cabdbc LibRegex: Use match_ordinary_characters() in ECMA262Parser::parse_atom()
Otherwise we would only match TokenType::Char, making all of these invalid:

- /foo,bar/
- /foo\/bar/
- /foo=bar/
- /foo-bar/
- /foo:bar/

Fixes #4243.
2020-11-29 20:35:52 +01:00
AnotherTest
5c8b48053e LibVT: Make terminal scrollback max size configurable 2020-11-29 20:32:45 +01:00
AnotherTest
158fe9d9ca LibRegex: Allow syntax characters (except ']') without escapes in classes
e.g. `[:]`
2020-11-29 20:32:10 +01:00
AnotherTest
129a58a2e5 LibCore: Do not try to null-terminate a ByteBuffer in read_line()
That's just silly :)
Also fix that one use of read_line() which assumes it will
null-terminated in mount.cpp (this would've blown up if the IODevice was
at EOF and had a line with the same size as max_size).
2020-11-29 20:32:10 +01:00
Andreas Kling
2d9d883274 LibJS: Add a basic implementation of String.prototype.substr() 2020-11-29 20:29:49 +01:00
Luke
d7455018eb LibGfx: gamma_to_linear4 is not a valid constexpr on clang 10 and below
This is a hack which can be removed once GitHub Actions changes the
default version to clang 11.

This is apparently sometime in mid-December.

Note, clang-11 is not currently available on Ubuntu 20.04. However,
GitHub Actions uses 20.04, which probably means clang-11 will
become available around that time for all 20.04 users.
2020-11-29 20:22:56 +01:00
Luke
72abf3491b LibCrypto: Require intent parameter in CTR constructor
This was preventing clang from building.
2020-11-29 20:22:56 +01:00
Nico Weber
1f22a59f9d LibGfx: Don't assert on files ending right before lzw_min_code_size
Not yet found by oss-fuzz, but I hit it a while ago when running
FuzzGIFLoader locally.
2020-11-29 20:21:30 +01:00
Nico Weber
86cec77eb5 LibGfx: skip zero-width frames
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27913
and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27873
2020-11-29 20:21:30 +01:00
Andreas Kling
2e4832c3da LibJS: Constructor function's "prototype" property should be writable
This matches other engines.
2020-11-29 19:49:27 +01:00
Andreas Kling
01c8765519 LibJS+LibWeb: Log JavaScript exceptions raised by web content
Instead of hiding JS exceptions raised on the web, we now print them to
the debug log. This will make it a bit easier to work out why some web
pages aren't working right. :^)
2020-11-29 16:50:32 +01:00
Andreas Kling
2dd03a4200 LibWeb: Abort event handling if underlying layout tree disappears
We didn't notice that the layout tree had disappeared after dispatching
a mousedown event, because we only checked EventHandler::layout_root()
which happily returned the *new* layout tree after a window.reload().

This patch fixes that by verifying that the frame is still showing the
same DOM's layout tree after event dispatch.

Fixes #4224.
2020-11-29 16:43:12 +01:00
Andreas Kling
4ebb57298b LibWeb: Allow building partial layout trees
We can now build partial layout trees (this happens for example when an
element's "display" property is programmatically toggled from "none" to
something else.)
2020-11-29 16:23:12 +01:00
Andreas Kling
127274fd42 LibWeb: Tweak a comment in Layout::TreeBuilder for accuracy 2020-11-29 16:23:12 +01:00
Andreas Kling
e424e4749f LibWeb: Allow <svg> layout boxes to have children
We can't say that "no replaced boxes can have children", since that
breaks SVG. Instead, let each LayoutNode decide whether it's allowed
to have children.

Fixes #4223.
2020-11-29 16:23:12 +01:00
devashish
4d7ba50dc7 JPGLoader: Move bogus JPEGs to a different directory 2020-11-29 16:22:04 +01:00
devashish
f107c70652 JPGLoader: Use HashMap instead of Vector for storing components
The JPEG spec allows component IDs to be chosen arbitrarily from the
interval [0, 255]. Storing components in a vector corrupts the decoder
when component IDs are not in the range 0-3. Normally, encoders don't
use IDs outside of that range because JPEG doesn't support more than
4 channels. But since there is a chance that a spec compliant JPEG
would have component IDs outside of [0-3], we should consider replacing
the vector, which enforces serial component access based on component
IDs, with a HashMap<u8, ComponentSpec>.
2020-11-29 16:22:04 +01:00
Andreas Kling
d4b2e89875 LibWeb: Blocks can have non-block (but non-inline) parents
We were messing up the box tree for tables by hoisting cells up to
become children of the table row group (instead of the table row.)

Table rows are non-block boxes, and it's fine for them to have cell
(block) children.

Fixes #4225.
2020-11-29 12:51:54 +01:00
Linus Groh
b5b4c50913 LibMarkdown: Only consider "!" a special character when followed by "["
Fixes #4220.
2020-11-29 10:45:00 +01:00
Linus Groh
cbe4595ec2 LibRegex: Fix clang build errors 2020-11-29 09:29:26 +01:00
Linus Groh
3ac7fb9f6c LibJS: Disallow 'with' statement in strict mode 2020-11-28 20:33:41 +01:00
Andreas Kling
42b1b36eb4 LibJS: Run clang-format on WithScope.h 2020-11-28 17:36:38 +01:00
Andreas Kling
1fad95fec5 LibJS: Add a basic unit test for the "with" statement 2020-11-28 17:16:48 +01:00
Andreas Kling
9de6443ab7 LibJS: Add basic support for "with" statements
with statements evaluate an expression and put the result of it at the
"front" of the scope chain. This is implemented by creating a WithScope
object and placing it in front of the VM's current call frame's scope.
2020-11-28 17:16:48 +01:00
Andreas Kling
c3fe9b4df8 LibJS: Add a scope object abstraction
Both GlobalObject and LexicalEnvironment now inherit from ScopeObject,
and the VM's call frames point to a ScopeObject chain rather than just
a LexicalEnvironment chain.

This gives us much more flexibility to implement things like "with",
and also unifies some of the code paths that previously required
special handling of the global object.

There's a bunch of more cleanup that can be done in the wake of this
change, and there might be some oversights in the handling of the
"super" keyword, but this generally seems like a good architectural
improvement. :^)
2020-11-28 17:16:48 +01:00
Andreas Kling
e1bbc7c075 LibJS: Make JS::Value constructors take const cell pointers
Taking non-const cell pointers is asking for trouble, since passing e.g
a "const Object*" to Value(Object*) will actually call Value(bool),
which is most likely not what you want.
2020-11-28 17:16:48 +01:00
Andreas Kling
d617120499 LibJS: Parse "with" statements :^) 2020-11-28 17:16:48 +01:00
Andreas Kling
98f2da9834 LibJS: Rename Cell::visit_children() => Cell::visit_edges()
The GC heap is really a graph of cells, so "children" didn't quite feel
appropriate here.
2020-11-28 17:16:48 +01:00
Andreas Kling
97a05ac9ac LibJS: Allow Shape without a global object
It would be nice to be able to cache some shapes globally in the VM,
but then they can't be tied to a specific global object. So let's just
get rid of the requirement that shapes are tied to a global object.
2020-11-28 17:16:48 +01:00
Linus Groh
d66087ac2f LibGUI/FileIconProvider: Initialize s_filetype_image_icon
This was accidentally removed in 1c90321.
Fixes #4125.
2020-11-28 17:16:33 +01:00
Linus Groh
149b54e26f LibJS: Remove quotes from RegExpCompileError message
They look a bit out of place, especially for multi-line error messages.
2020-11-28 16:46:25 +01:00
Linus Groh
7615649fdf LibRegex: Remove trailing newline from error_string() 2020-11-28 16:46:25 +01:00
Linus Groh
ca8e5b0791 LibRegex: Don't print error message in Regex constructor
It should be up to the caller to decide what to do when parsing of the
pattern fails.
2020-11-28 16:46:25 +01:00
Andreas Kling
1abda05d38 LibGUI: Make GUI::Dialogs non-minimizable by default 2020-11-28 10:26:05 +01:00
Andreas Kling
005afa4c6e LibGUI: Don't assert when right clicking on a vertical HeaderView
Just log a debug message instead. We still need to actually implement
vertical header context menus, but for now let's at least not crash.
2020-11-28 10:26:05 +01:00
AnotherTest
491e4a8a3b LibRegex: Allow '-' as the last element of a charclass
Fixes #4189.
2020-11-28 10:13:33 +01:00
AnotherTest
e2fa1b40c4 LibRegex: Allow unknown escapes in non-unicode mode (for ECMA262)
This makes regexps like `/\x/` to work as normal.
Partially deals with #4189.
2020-11-28 10:13:33 +01:00