Commit d3ed1c91 authored by cblu's avatar cblu

WebFoundation:

	Fixed: 3143656 - crash in MIMETypeForFile when a large QT movie is dragged over window

	Removed all unnecessary content sniffing as that work is already done in WebResourceLoad.

        Reviewed by darin.

        * CacheLoader.subproj/WebResourceLoad.m:
        (-[WebResourceLoad _sendResponseMetadataCallbackCheckingPreconditions:]): only sniff here, call _web_guessedMIMEType
        * Misc.subproj/WebMultipartForm.m: include WebNSDataExtras
        * Misc.subproj/WebNSDataExtras.h: Added.
        * Misc.subproj/WebNSDataExtras.m: Added.
        (-[NSMutableData _web_appendFormat:]):
        (-[NSMutableData _web_appendEncodedString:format:arguments:]):
        (-[NSMutableData _web_appendEncodedString:format:]):
        (-[NSData _web_guessedMIMEType]): was _guessMIMEType in WebResourceLoad
        * Misc.subproj/WebNSMutableDataExtras.h: Removed.
        * Misc.subproj/WebNSMutableDataExtras.m: Removed.
        * Misc.subproj/WebNSStringExtras.h: removed 2 unneeded methods
        * Misc.subproj/WebNSStringExtras.m:
        * ProtocolHandlers.subproj/WebFileProtocolHandler.m:
        (-[WebFileProtocolHandler didLoadData:]): get the MIME type from the extension, don't sniff
        * ProtocolHandlers.subproj/WebSimpleHTTPProtocolHandler.m:
        (-[WebSimpleHTTPProtocolHandler _extractResponseStatusLineFromBytes:length:]): don't sniff
        * WebFoundation.pbproj/project.pbxproj:

WebKit:

	Fixed: 3143656 - crash in MIMETypeForFile when a large QT movie is dragged over window

        Reviewed by darin.

        * WebView.subproj/WebControllerPrivate.m:
        (+[WebController _MIMETypeForFile:]): rewrote, now calls _web_guessedMIMEType


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1bd92ea0
2003-01-17 Chris Blumenberg <cblu@apple.com>
Fixed: 3143656 - crash in MIMETypeForFile when a large QT movie is dragged over window
Reviewed by darin.
* WebView.subproj/WebControllerPrivate.m:
(+[WebController _MIMETypeForFile:]): rewrote, now calls _web_guessedMIMEType
2003-01-17 Darin Adler <darin@apple.com>
- compressed all our non-compressed TIFF files
......
......@@ -21,6 +21,7 @@
#import <WebFoundation/WebCacheLoaderConstants.h>
#import <WebFoundation/WebError.h>
#import <WebFoundation/WebFileTypeMappings.h>
#import <WebFoundation/WebNSDataExtras.h>
#import <WebFoundation/WebNSStringExtras.h>
#import <WebFoundation/WebResourceHandle.h>
#import <WebFoundation/WebResourceRequest.h>
......@@ -169,29 +170,30 @@ - (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dat
}
}
+ (NSString *)_MIMETypeForFile: (NSString *)path
+ (NSString *)_MIMETypeForFile:(NSString *)path
{
NSString *result;
NSString *extension = [path pathExtension];
if ([extension isEqualToString:@""]) {
result = @"text/html";
NSString *MIMEType = nil;
// Get the MIME type from the extension.
if ([extension length] != 0) {
MIMEType = [[WebFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
}
else {
result = [[WebFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
if (!result || [result isEqualToString:@"application/octet-stream"]) {
NSString *contents = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:path]
encoding:NSASCIIStringEncoding];
if([contents _web_looksLikeHTMLDocument]){
result = @"text/html";
}else{
result = @"application/octet-stream";
}
[contents release];
// If we can't get a known MIME type from the extension, sniff.
if ([MIMEType length] == 0 || [MIMEType isEqualToString:@"application/octet-stream"]) {
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
NSData *data = [handle readDataOfLength:GUESS_MIME_TYPE_PEEK_LENGTH];
[handle closeFile];
if ([data length] != 0) {
MIMEType = [data _web_guessedMIMEType];
}
if ([MIMEType length] == 0){
MIMEType = @"application/octet-stream";
}
}
return result;
return MIMEType;
}
+ (NSArray *)_supportedImageMIMETypes
......
......@@ -21,6 +21,7 @@
#import <WebFoundation/WebCacheLoaderConstants.h>
#import <WebFoundation/WebError.h>
#import <WebFoundation/WebFileTypeMappings.h>
#import <WebFoundation/WebNSDataExtras.h>
#import <WebFoundation/WebNSStringExtras.h>
#import <WebFoundation/WebResourceHandle.h>
#import <WebFoundation/WebResourceRequest.h>
......@@ -169,29 +170,30 @@ - (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dat
}
}
+ (NSString *)_MIMETypeForFile: (NSString *)path
+ (NSString *)_MIMETypeForFile:(NSString *)path
{
NSString *result;
NSString *extension = [path pathExtension];
if ([extension isEqualToString:@""]) {
result = @"text/html";
NSString *MIMEType = nil;
// Get the MIME type from the extension.
if ([extension length] != 0) {
MIMEType = [[WebFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
}
else {
result = [[WebFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
if (!result || [result isEqualToString:@"application/octet-stream"]) {
NSString *contents = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:path]
encoding:NSASCIIStringEncoding];
if([contents _web_looksLikeHTMLDocument]){
result = @"text/html";
}else{
result = @"application/octet-stream";
}
[contents release];
// If we can't get a known MIME type from the extension, sniff.
if ([MIMEType length] == 0 || [MIMEType isEqualToString:@"application/octet-stream"]) {
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
NSData *data = [handle readDataOfLength:GUESS_MIME_TYPE_PEEK_LENGTH];
[handle closeFile];
if ([data length] != 0) {
MIMEType = [data _web_guessedMIMEType];
}
if ([MIMEType length] == 0){
MIMEType = @"application/octet-stream";
}
}
return result;
return MIMEType;
}
+ (NSArray *)_supportedImageMIMETypes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment