Commit Graph

47 Commits

Author SHA1 Message Date
Kemal Zebari
8e5410347b LibWeb/MimeSniff: Add non-standard text or binary context sniffing
This is used in cases where the spec expects us to only run the
"rules for distinguishing if a resource is a text or binary" algo.
2024-02-02 14:34:17 -05:00
Kemal Zebari
f2c1130f23 LibWeb/MimeSniff: Remove unnecessary addition in mp4 signature match
A little whoopsie I did not see in 3aaa1c1. This is not erroneous
behavior, but it's just not necessary.
2024-01-12 19:24:35 -07:00
Kemal Zebari
3aaa1c1df7 LibWeb/MimeSniff: Implement MP4 signature matching 2024-01-12 17:12:47 -07:00
Kemal Zebari
5d14691149 LibWeb: Add rules for distinguishing if a resource is text or binary
Resolves a FIXME in MimeSniff::Resource allowing us to determine
the computed MIME type given supplied types that are used in older
versions of Apache that need special handling.
2024-01-04 12:25:38 -07:00
Kemal Zebari
0b7148e2a6 LibWeb/MimeSniff: Add sniffing in a font context 2024-01-04 12:25:38 -07:00
Kemal Zebari
3a820ddbdf LibWeb/MimeSniff: Add sniffing in an audio or video context 2023-12-07 10:31:54 -07:00
Kemal Zebari
02ea85da2c LibWeb/MimeSniff: Add sniffing in an image context 2023-12-07 10:31:54 -07:00
Kemal Zebari
ea15501f37 LibWeb/MimeSniff: Add sniffing in a browsing context 2023-12-07 10:31:54 -07:00
Kemal Zebari
f6d3ea33fa LibWeb/MimeSniff: Add match an archive type pattern algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
d5e5a1138f LibWeb/MimeSniff: Add match an audio or video type pattern algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
62ca3b518b LibWeb/MimeSniff: Add the image type pattern matching algorithm 2023-12-07 10:31:54 -07:00
Kemal Zebari
2babc08c17 LibWeb/MimeSniff: Add rules for identifying an unknown mime type
This also implements the pattern matching algorithm since it's
needed.
2023-12-07 10:31:54 -07:00
Kemal Zebari
04e19df06a LibWeb/MimeSniff: Implement Resource
See https://mimesniff.spec.whatwg.org/#resource
2023-12-07 10:31:54 -07:00
Kemal Zebari
a2a61d6941 LibWeb/MimeSniff: Add move/copy construct and assignment to MimeType
This change exists to avoid having to reparse a MIME type when we
need to move/copy elsewhere.
2023-12-07 10:31:54 -07:00
Kemal Zebari
34fa49c344 LibWeb/MimeSniff: Add missing spec comments 2023-12-07 11:11:07 +01:00
Kemal Zebari
e80d3ff518 LibWeb: Have MimeType::create() match its foward declaration 2023-11-14 10:14:09 +01:00
Kemal Zebari
6b37095ffd LibWeb: Validate MimeType(String, String) arguments correctly
This commit correctly validates the `type` and `subtype` arguments,
instead of checking for http quoted code points, by following how
the spec's MIME type parsing algorithm would validate a MIME type's
type and subtype.

It also uses the move-assigned member variables instead of the
arguments within the constructor body (as using the arguments at
this point will lead to undesired behavior).
2023-11-14 10:14:09 +01:00
Kemal Zebari
355e373ce5 LibWeb/MimeSniff: Add MimeType::is_json() 2023-10-04 09:20:47 +01:00
Kemal Zebari
b110e4649e LibWeb/MimeSniff: Add MimeType::is_scriptable() 2023-10-04 09:20:47 +01:00
Kemal Zebari
644cc1d7ee LibWeb/MimeSniff: Add MimeType::is_archive() 2023-10-04 09:20:47 +01:00
Kemal Zebari
99a47b9276 LibWeb/MimeSniff: Add MimeType::is_zip_based() 2023-10-04 09:20:47 +01:00
Kemal Zebari
75c42258f2 LibWeb/MimeSniff: Add MimeType::is_font() 2023-10-04 09:20:47 +01:00
Kemal Zebari
3a0fa0e471 LibWeb/MimeSniff: Add MimeType::is_audio_or_video() 2023-10-04 09:20:47 +01:00
Kemal Zebari
d2c88faf00 LibWeb/MimeSniff: Add MimeType::is_image() 2023-10-04 09:20:47 +01:00
Shannon Booth
132b17406b LibWeb: Add missing String.h include to MimeSniff/MimeType.h
This doesn't cause any compiler errors, but clang-tidy in my editor
certainly complains that this include is missing.
2023-09-17 16:37:31 -06:00
Bastiaan van der Plaat
222cc29c5c LibWeb: Add XMLHttpRequest Document response type 2023-09-14 22:58:42 +02:00
Ben Wiederhake
560133a0c6 Everywhere: Remove unused DeprecatedString includes 2023-04-09 22:00:54 +02:00
Linus Groh
f65cbeef5c LibWeb/Infra: Rename to_ascii_{{lower,upper}_case => {lower,upper}case} 2023-03-04 22:42:42 +00:00
Linus Groh
2d7ce38ee2 LibWeb/MimeSniff: Port MimeType to new String 2023-03-03 11:02:21 +00:00
Linus Groh
fabea2a6a7 LibWeb/MimeSniff: Rename MimeType::from_string() to MimeType::parse()
This matches the spec's "parse a MIME type".
2023-03-03 11:02:21 +00:00
Linus Groh
11023a3c53 LibWeb/Fetch: Port infrastructure to new String 2023-03-03 09:25:34 +00:00
Sam Atkins
c06f4ac6f5 AK+Everywhere: Make GenericLexer::ignore_until() stop before the value
`consume_until(foo)` stops before foo, and so does
`ignore_until(Predicate)`, so let's make the other `ignore_until()`
overloads consistent with that so they're less confusing.
2023-02-28 12:55:10 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Nico Weber
0175b5c584 LibWeb: Merge latest mimesniff spec update
Merges https://github.com/whatwg/mimesniff/commit/e589fcb71196,
an editorial change...that fixes a comment typo!
2022-11-11 12:13:09 +00:00
networkException
297e293a3f LibWeb: Implement more close to spec javascript mime type checking
Previously we would simply check the an input string against a list of
mime type essences, ignoring that the input might not be a valid mime
type or contain parameters.

This patch moves the helpers into the MimeSniff namespace and properly
parses an input string before comparing the essence.
2022-10-06 16:41:36 +02:00
Nico Weber
bf6d5fce18 LibWeb: In MimeType serialization, put just one \ in front of each " 2022-09-27 15:47:54 +01:00
Linus Groh
b42b950688 LibWeb: Implement MimeType serialization 2022-09-27 14:56:17 +01:00
Linus Groh
2726fc9c73 LibWeb: Move Fetch infra into the Web::Fetch::Infrastructure namespace
The Fetch spec unfortunately will cause a name clash between the Request
concept and the Request JS object - both cannot live in the Web::Fetch
namespace, and WrapperGenerator generally assumes `Web::<Name>` for
things living in the `<Name>/` subdirectory, so let's instead move infra
code into its own namespace - it already sits in a (sub-)subdirectory
anyway.
2022-07-19 00:27:35 +01:00
Linus Groh
fad69fcacd LibWeb: Move Fetch::collect_an_http_quoted_string() into HTTP.{cpp,h}
The Fetch spec is too big to have a generic AbstractOperations.{cpp,h}
file, so let's keep AOs in their section-specific files.
2022-07-14 00:42:26 +01:00
Linus Groh
e3798886ed LibWeb: Add & use 'HTTP whitespace' from '2.2. HTTP' in the Fetch spec
We had two independent definitions of this already, both referring to
the Fetch spec.
2022-07-14 00:42:26 +01:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Hendiadyoin1
6e921ae304 LibWeb: Move passed string in MimeType constructor
This was pointed out by Clang-Tidy and should avoid an allocation.
2022-03-21 10:48:17 +01:00
Lenny Maiorani
c37820b898 Libraries: Use default constructors/destructors in LibWeb
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-17 17:23:49 +00:00
Luke Wilde
d1c4a94659 LibWeb: Fix comparing current position to quote in Mime Type quote parse
Had a look over this with a fresh head and noticed I was comparing the
current lexer position to the quote character, oops!
2022-02-12 17:13:14 +00:00
Luke Wilde
8cfeca5261 LibWeb: Implement spec-compliant MIME type struct and parser
This will be used by XHR to extract the Content-Type MIME type to
retrieve the charset.
2022-02-12 12:53:28 +01:00