Home | History | Annotate | Download | only in base

Lines Matching refs:content

9 // HTML payload, no Content-Type header:
18 // HTML payload, Content-Type: "text/plain":
28 // We generalize this as follows. If the Content-Type header is text/plain
31 // HTML payload, Content-Type: "application/octet-stream":
44 // GIF payload, no Content-Type header:
53 // Once we decide to render HTML without a Content-Type header, there isn't much
56 // GIF payload, Content-Type: "text/plain":
64 // Displaying as text/plain makes little sense as the content will look like
68 // GIF payload, Content-Type: "application/octet-stream":
78 // should be sending Content-Disposition: attachment). Although it is safe
83 // XHTML payload, Content-Type: "text/xml":
108 // The number of content bytes we need to use all our magic numbers. Feel free
174 // vulnerability if the site allows users to upload content.
220 // Compare content header to a magic number where magic_entry can contain '.'
222 static bool MagicCmp(const char* magic_entry, const char* content, size_t len) {
224 if ((*magic_entry != '.') && (*magic_entry != *content))
227 ++content;
233 static bool MatchMagicNumber(const char* content, size_t size,
241 // To compare with magic strings, we need to compute strlen(content), but
242 // content might not actually have a null terminator. In that case, we
245 static_cast<const char*>(memchr(content, '\0', size));
247 (end != NULL) ? static_cast<size_t>(end - content) : size;
253 match = (base::strncasecmp(magic_entry->magic, content, len) == 0);
257 match = MagicCmp(magic_entry->magic, content, len);
267 static bool CheckForMagicNumbers(const char* content, size_t size,
272 if (MatchMagicNumber(content, size, &(magic[i]), result)) {
293 // Returns true and sets result if the content appears to be HTML.
295 static bool SniffForHTML(const char* content,
305 const char* const end = content + size;
307 for (pos = content; pos < end; ++pos) {
321 // Returns true and sets result if the content matches any of kMagicNumbers.
323 static bool SniffForMagicNumbers(const char* content,
334 return CheckForMagicNumbers(content, size,
341 // We want to be very conservative in interpreting text/xml content as
351 // Returns true and sets result if the content appears to contain XHTML or a
359 static bool SniffXML(const char* content,
363 // We allow at most 300 bytes of content before we expect the opening tag.
365 const char* pos = content;
366 const char* const end = content + size;
407 // If we have more content to look at, we aren't going to change our mind by
419 // Whether a given byte looks like it might be part of binary content.
440 // Returns true and sets result to "application/octet-stream" if the content
443 static bool SniffBinary(const char* content,
447 // There is no concensus about exactly how to sniff for binary content.
462 if (CheckForMagicNumbers(content, size,
472 // If we a see a binary-looking byte, we think the content is binary.
473 if (kByteLooksBinary[static_cast<unsigned char>(content[i])]) {
518 // Returns true and sets result if the content appears to be a crx (chrome
521 static bool SniffCRX(const char* content,
554 if (CheckForMagicNumbers(content, size,
583 // different types of content.
605 // The web server didn't specify a content type or specified a mime
615 bool SniffMimeType(const char* content, size_t content_size,
619 DCHECK(content);
622 // By default, we assume we have enough content.
623 // Each sniff routine may unset this if it wasn't provided enough content.
638 if (SniffForHTML(content, content_size, &have_enough_content, result))
639 return true; // We succeeded in sniffing HTML. No more content needed.
650 if (!SniffBinary(content, content_size, &have_enough_content, result)) {
651 // If the server said the content was text/plain and it doesn't appear
664 if (SniffXML(content, content_size, &have_enough_content, result))
671 if (SniffCRX(content, content_size, url, type_hint,
681 // anything that matches the content.
682 if (SniffForMagicNumbers(content, content_size,
684 return true; // We've matched a magic number. No more content needed.