NetSurf
|
MIME type sniffer implementation. More...
#include <string.h>
#include <strings.h>
#include "utils/http.h"
#include "utils/utils.h"
#include "utils/corestrings.h"
#include "content/content_factory.h"
#include "content/mimesniff.h"
Go to the source code of this file.
Data Structures | |
struct | map_s |
Macros | |
#define | SIG(t, s, x) { (const uint8_t *) s, SLEN(s), x, t } |
#define | SIG(t, s, x) { (const uint8_t *) s, SLEN(s), x, t } |
#define | SIG(t, s, x) { (const uint8_t *) s, SLEN(s), x, t } |
#define | SIG(t, s, x) { (const uint8_t *) s, SLEN(s), x, t } |
#define | SIG(t, s) { (const uint8_t *) s, SLEN(s), t } |
#define | RDF_NS "http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
#define | RSS_NS "http://purl.org/rss/1.0" |
#define | MATCH(s) |
#define | S(s) { s, SLEN(s) } |
Functions | |
static bool | mimesniff__has_binary_octets (const uint8_t *data, size_t len) |
static nserror | mimesniff__match_mp4 (const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__match_unknown_ws (const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__match_unknown_bom (const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__match_unknown_riff (const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__match_unknown_exact (const uint8_t *data, size_t len, bool allow_unsafe, lwc_string **effective_type) |
static nserror | mimesniff__match_unknown (const uint8_t *data, size_t len, bool allow_unsafe, lwc_string **effective_type) |
static nserror | mimesniff__compute_unknown (const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__compute_text_or_binary (const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__compute_image (lwc_string *official_type, const uint8_t *data, size_t len, lwc_string **effective_type) |
static nserror | mimesniff__compute_feed_or_html (const uint8_t *data, size_t len, lwc_string **effective_type) |
nserror | mimesniff_compute_effective_type (const char *content_type_header, const uint8_t *data, size_t len, bool sniff_allowed, bool image_only, lwc_string **effective_type) |
Compute the effective MIME type for an object. More... | |
#define RDF_NS "http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
#define RSS_NS "http://purl.org/rss/1.0" |
#define S | ( | s | ) | { s, SLEN(s) } |
#define SIG | ( | t, | |
s | |||
) | { (const uint8_t *) s, SLEN(s), t } |
#define SIG | ( | t, | |
s, | |||
x | |||
) | { (const uint8_t *) s, SLEN(s), x, t } |
#define SIG | ( | t, | |
s, | |||
x | |||
) | { (const uint8_t *) s, SLEN(s), x, t } |
#define SIG | ( | t, | |
s, | |||
x | |||
) | { (const uint8_t *) s, SLEN(s), x, t } |
#define SIG | ( | t, | |
s, | |||
x | |||
) | { (const uint8_t *) s, SLEN(s), x, t } |
|
static |
Definition at line 426 of file mimesniff.c.
References MATCH, min, NSERROR_NEED_DATA, NSERROR_OK, RDF_NS, RSS_NS, and SLEN.
Referenced by mimesniff_compute_effective_type().
|
static |
Definition at line 371 of file mimesniff.c.
References image_types, NSERROR_NEED_DATA, NSERROR_OK, SIG, SLEN, and type.
Referenced by mimesniff_compute_effective_type().
|
static |
Definition at line 338 of file mimesniff.c.
References map_s::len, mimesniff__has_binary_octets(), mimesniff__match_unknown(), min, NSERROR_NEED_DATA, and NSERROR_OK.
Referenced by mimesniff_compute_effective_type().
|
static |
Definition at line 314 of file mimesniff.c.
References map_s::len, mimesniff__has_binary_octets(), mimesniff__match_unknown(), min, NSERROR_NEED_DATA, and NSERROR_OK.
Referenced by mimesniff_compute_effective_type().
|
static |
Definition at line 43 of file mimesniff.c.
Referenced by mimesniff__compute_text_or_binary(), and mimesniff__compute_unknown().
|
static |
Definition at line 61 of file mimesniff.c.
References NSERROR_NOT_FOUND, and NSERROR_OK.
Referenced by mimesniff__match_unknown().
|
static |
Definition at line 286 of file mimesniff.c.
References map_s::len, mimesniff__match_mp4(), mimesniff__match_unknown_bom(), mimesniff__match_unknown_exact(), mimesniff__match_unknown_riff(), mimesniff__match_unknown_ws(), NSERROR_NOT_FOUND, and NSERROR_OK.
Referenced by mimesniff__compute_text_or_binary(), and mimesniff__compute_unknown().
|
static |
Definition at line 197 of file mimesniff.c.
References map_s::len, NSERROR_NOT_FOUND, NSERROR_OK, map_s::sig, SIG, and map_s::type.
Referenced by mimesniff__match_unknown().
|
static |
Definition at line 245 of file mimesniff.c.
References map_s::len, NSERROR_NOT_FOUND, NSERROR_OK, map_s::safe, map_s::sig, SIG, and map_s::type.
Referenced by mimesniff__match_unknown().
|
static |
Definition at line 220 of file mimesniff.c.
References map_s::len, NSERROR_NOT_FOUND, NSERROR_OK, map_s::sig, SIG, SLEN, and map_s::type.
Referenced by mimesniff__match_unknown().
|
static |
Definition at line 124 of file mimesniff.c.
References map_s::len, NSERROR_NOT_FOUND, NSERROR_OK, map_s::sig, SIG, and map_s::type.
Referenced by mimesniff__match_unknown().
nserror mimesniff_compute_effective_type | ( | const char * | content_type_header, |
const uint8_t * | data, | ||
size_t | len, | ||
bool | sniff_allowed, | ||
bool | image_only, | ||
lwc_string ** | effective_type | ||
) |
Compute the effective MIME type for an object.
The implementation uses the sniffing algorithm described in http://mimesniff.spec.whatwg.org/
content_type_header | Source content type header |
data | First data chunk, or NULL |
len | Length of data, in bytes |
sniff_allowed | Whether MIME type sniffing is allowed |
image_only | Sniff image types only |
effective_type | Location to receive computed type |
Definition at line 563 of file mimesniff.c.
References content_factory_type_from_mime_type(), CONTENT_IMAGE, http_content_type_destroy(), http_parse_content_type(), http_content_type::media_type, mimesniff__compute_feed_or_html(), mimesniff__compute_image(), mimesniff__compute_text_or_binary(), mimesniff__compute_unknown(), NSERROR_NOT_FOUND, NSERROR_OK, S, and SLEN.
Referenced by hlcache_llcache_callback().