[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:19:29 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit bd135e1693c16ca3f0c29f5f9ad91a27fb734823
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 14 02:02:57 2003 +0000
WebFoundation:
Fix for checking and creating proper download filenames.
Reviewed by mjs, kocienda, trey.
* CacheLoader.subproj/WebResourceResponse.h:
* CacheLoader.subproj/WebResourceResponse.m: removed the filename method. That is now a category in WebKit
* CacheLoader.subproj/WebResourceResponsePrivate.h:
* Misc.subproj/WebNSStringExtras.h:
* Misc.subproj/WebNSStringExtras.m:
(-[NSString _web_filenameByFixingIllegalCharacters]): new, turns "/" into "-", strips leading dots
* ProtocolHandlers.subproj/WebHTTPProtocolHandler.m:
(-[WebHTTPProtocolHandler setResponseMetadata:]): don't parse out the content disposition. This is done in WebKit.
WebKit:
Fix for checking and creating proper download filenames.
Reviewed by mjs, kocienda, trey.
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/WebControllerPolicyDelegate.h: changes for renamed savePathForResponse:andRequest: method
* WebView.subproj/WebDefaultPolicyDelegate.m: changes for renamed savePathForResponse:andRequest: method
(-[WebDefaultPolicyDelegate savePathForResponse:andRequest:]): renamed
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient continueAfterContentPolicy:response:]): changes for renamed savePathForResponse:andRequest: method
WebBrowser:
Fix for checking and creating proper download filenames.
Reviewed by mjs, kocienda, trey.
* BrowserDocument.m:
(-[BrowserDocument pageName]): call _web_filenameByFixingIllegalCharacters on the web page title when saving the document
* BrowserWebController.m:
(-[BrowserWebController savePathForResponse:andRequest:]): renamed, removed temporary that checks for invalid filename. That work is done in WebKit.
* HTMLSourceDocument.m:
(-[HTMLSourceDocument displayName]): call suggestedFilenameForSaving
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 4935dd6..3c1cdba 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,16 @@
+2003-01-12 Chris Blumenberg <cblu at apple.com>
+
+ Fix for checking and creating proper download filenames.
+
+ Reviewed by mjs, kocienda, trey.
+
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/WebControllerPolicyDelegate.h: changes for renamed savePathForResponse:andRequest: method
+ * WebView.subproj/WebDefaultPolicyDelegate.m: changes for renamed savePathForResponse:andRequest: method
+ (-[WebDefaultPolicyDelegate savePathForResponse:andRequest:]): renamed
+ * WebView.subproj/WebMainResourceClient.m:
+ (-[WebMainResourceClient continueAfterContentPolicy:response:]): changes for renamed savePathForResponse:andRequest: method
+
2003-01-12 Darin Adler <darin at apple.com>
Reviewed by John.
diff --git a/WebKit/Misc.subproj/WebNSURLResponseExtras.h b/WebKit/Misc.subproj/WebNSURLResponseExtras.h
new file mode 100644
index 0000000..8292156
--- /dev/null
+++ b/WebKit/Misc.subproj/WebNSURLResponseExtras.h
@@ -0,0 +1,25 @@
+/*
+ WebResourceResponseExtras.h
+ Copyright 2003, Apple, Inc. All rights reserved.
+
+ Public header file.
+*/
+
+#import <WebFoundation/WebResourceResponse.h>
+
+ at interface WebResourceResponse (WebResourceResponseExtras)
+
+/*!
+ @method suggestedFilenameForSaving
+ @abstract Returns a suggested filename if the resource were saved to disk.
+ @discussion The method first checks if the server has specified a filename using the
+ content disposition header. If no valid filename is specified using that mechanism,
+ this method checks the last path component of the URL. If no valid filename can be
+ obtained using the last path component, this method uses the URL's host as the filename.
+ If the URL's host can't be converted to a valid filename, the filename "unknown" is used.
+ In mose cases, this method appends the proper file extension based on the MIME type.
+ This method always returns a valid filename.
+*/
+- (NSString *)suggestedFilenameForSaving;
+
+ at end
diff --git a/WebKit/Misc.subproj/WebNSURLResponseExtras.m b/WebKit/Misc.subproj/WebNSURLResponseExtras.m
new file mode 100644
index 0000000..78cb060
--- /dev/null
+++ b/WebKit/Misc.subproj/WebNSURLResponseExtras.m
@@ -0,0 +1,98 @@
+//
+// WebResourceResponseExtras.m
+// WebKit
+//
+// Created by Chris Blumenberg on Thu Jan 09 2003.
+// Copyright (c) 2003 Apple Inc. All rights reserved.
+//
+
+#import <WebKit/WebResourceResponseExtras.h>
+
+#import <WebFoundation/WebAssertions.h>
+#import <WebFoundation/WebFileTypeMappings.h>
+#import <WebFoundation/WebHTTPResourceResponse.h>
+#import <WebFoundation/WebLocalizableStrings.h>
+#import <WebFoundation/WebNSStringExtras.h>
+
+ at interface NSURL (WebResourceResponseInternalURLExtras)
+- (NSString *)_web_suggestedFilenameForSavingWithMIMEType:(NSString *)MIMEType;
+ at end
+
+ at implementation WebResourceResponse (WebResourceResponseExtras)
+
+- (NSString *)suggestedFilenameForSaving
+{
+ ASSERT([self URL]);
+
+ // Get the filename from the URL and the MIME type. Always returns something valid.
+ return [[self URL] _web_suggestedFilenameForSavingWithMIMEType:[self contentType]];
+}
+
+ at end
+
+ at implementation WebHTTPResourceResponse (WebResourceResponseExtras)
+
+- (NSString *)suggestedFilenameForSaving
+{
+ NSString *filename = nil;
+
+ // Use the content disposition of the filename if present.
+ NSString *contentDispositionHeader = [[self headers] objectForKey:@"Content-Disposition"];
+ filename = [contentDispositionHeader _web_fileNameFromContentDispositionHeader];
+ filename = [filename _web_filenameByFixingIllegalCharacters];
+
+ if ([filename length] == 0) {
+ // Get the filename from the URL and the MIME type. Always returns something valid.
+ filename = [super suggestedFilenameForSaving];
+ }
+
+ return filename;
+}
+
+ at end
+
+ at implementation NSURL (WebResourceResponseInternalURLExtras)
+
+- (NSString *)_web_suggestedFilenameForSavingWithMIMEType:(NSString *)MIMEType
+{
+ // Get the filename from the URL. Try the lastPathComponent first.
+ NSString *filename = [[[self path] lastPathComponent] _web_filenameByFixingIllegalCharacters];
+ NSString *extension = nil;
+
+ if ([filename length] == 0) {
+ // lastPathComponent is no good, try the host.
+ filename = [[self host] _web_filenameByFixingIllegalCharacters];
+ if ([filename length] == 0) {
+ // Can't make a filename using this URL, use "unknown".
+ filename = UI_STRING("unknown", "Unknown filename");
+ }
+ } else {
+ // Save the extension for later correction. Only correct the extension of the lastPathComponent.
+ // For example, if the filename ends up being the host, we wouldn't want to correct ".com" in "www.apple.com".
+ extension = [filename pathExtension];
+ }
+
+ // If the type is known, check the extension and correct it if necessary.
+ if (MIMEType && ![MIMEType isEqualToString:@"application/octet-stream"]) {
+ WebFileTypeMappings *mappings = [WebFileTypeMappings sharedMappings];
+ NSArray *extensions = [mappings extensionsForMIMEType:MIMEType];
+
+ if (![extension length] || (extensions && ![extensions containsObject:extension])) {
+ // The extension doesn't match the MIME type. Correct this.
+ NSString *correctExtension = [mappings preferredExtensionForMIMEType:MIMEType];
+ if ([correctExtension length] != 0) {
+ if ([extension length] != 0) {
+ // Remove the incorrect extension.
+ filename = [filename stringByDeletingPathExtension];
+ }
+
+ // Append the correct extension.
+ filename = [filename stringByAppendingPathExtension:correctExtension];
+ }
+ }
+ }
+
+ return filename;
+}
+
+ at end
\ No newline at end of file
diff --git a/WebKit/Misc.subproj/WebResourceResponseExtras.h b/WebKit/Misc.subproj/WebResourceResponseExtras.h
new file mode 100644
index 0000000..8292156
--- /dev/null
+++ b/WebKit/Misc.subproj/WebResourceResponseExtras.h
@@ -0,0 +1,25 @@
+/*
+ WebResourceResponseExtras.h
+ Copyright 2003, Apple, Inc. All rights reserved.
+
+ Public header file.
+*/
+
+#import <WebFoundation/WebResourceResponse.h>
+
+ at interface WebResourceResponse (WebResourceResponseExtras)
+
+/*!
+ @method suggestedFilenameForSaving
+ @abstract Returns a suggested filename if the resource were saved to disk.
+ @discussion The method first checks if the server has specified a filename using the
+ content disposition header. If no valid filename is specified using that mechanism,
+ this method checks the last path component of the URL. If no valid filename can be
+ obtained using the last path component, this method uses the URL's host as the filename.
+ If the URL's host can't be converted to a valid filename, the filename "unknown" is used.
+ In mose cases, this method appends the proper file extension based on the MIME type.
+ This method always returns a valid filename.
+*/
+- (NSString *)suggestedFilenameForSaving;
+
+ at end
diff --git a/WebKit/Misc.subproj/WebResourceResponseExtras.m b/WebKit/Misc.subproj/WebResourceResponseExtras.m
new file mode 100644
index 0000000..78cb060
--- /dev/null
+++ b/WebKit/Misc.subproj/WebResourceResponseExtras.m
@@ -0,0 +1,98 @@
+//
+// WebResourceResponseExtras.m
+// WebKit
+//
+// Created by Chris Blumenberg on Thu Jan 09 2003.
+// Copyright (c) 2003 Apple Inc. All rights reserved.
+//
+
+#import <WebKit/WebResourceResponseExtras.h>
+
+#import <WebFoundation/WebAssertions.h>
+#import <WebFoundation/WebFileTypeMappings.h>
+#import <WebFoundation/WebHTTPResourceResponse.h>
+#import <WebFoundation/WebLocalizableStrings.h>
+#import <WebFoundation/WebNSStringExtras.h>
+
+ at interface NSURL (WebResourceResponseInternalURLExtras)
+- (NSString *)_web_suggestedFilenameForSavingWithMIMEType:(NSString *)MIMEType;
+ at end
+
+ at implementation WebResourceResponse (WebResourceResponseExtras)
+
+- (NSString *)suggestedFilenameForSaving
+{
+ ASSERT([self URL]);
+
+ // Get the filename from the URL and the MIME type. Always returns something valid.
+ return [[self URL] _web_suggestedFilenameForSavingWithMIMEType:[self contentType]];
+}
+
+ at end
+
+ at implementation WebHTTPResourceResponse (WebResourceResponseExtras)
+
+- (NSString *)suggestedFilenameForSaving
+{
+ NSString *filename = nil;
+
+ // Use the content disposition of the filename if present.
+ NSString *contentDispositionHeader = [[self headers] objectForKey:@"Content-Disposition"];
+ filename = [contentDispositionHeader _web_fileNameFromContentDispositionHeader];
+ filename = [filename _web_filenameByFixingIllegalCharacters];
+
+ if ([filename length] == 0) {
+ // Get the filename from the URL and the MIME type. Always returns something valid.
+ filename = [super suggestedFilenameForSaving];
+ }
+
+ return filename;
+}
+
+ at end
+
+ at implementation NSURL (WebResourceResponseInternalURLExtras)
+
+- (NSString *)_web_suggestedFilenameForSavingWithMIMEType:(NSString *)MIMEType
+{
+ // Get the filename from the URL. Try the lastPathComponent first.
+ NSString *filename = [[[self path] lastPathComponent] _web_filenameByFixingIllegalCharacters];
+ NSString *extension = nil;
+
+ if ([filename length] == 0) {
+ // lastPathComponent is no good, try the host.
+ filename = [[self host] _web_filenameByFixingIllegalCharacters];
+ if ([filename length] == 0) {
+ // Can't make a filename using this URL, use "unknown".
+ filename = UI_STRING("unknown", "Unknown filename");
+ }
+ } else {
+ // Save the extension for later correction. Only correct the extension of the lastPathComponent.
+ // For example, if the filename ends up being the host, we wouldn't want to correct ".com" in "www.apple.com".
+ extension = [filename pathExtension];
+ }
+
+ // If the type is known, check the extension and correct it if necessary.
+ if (MIMEType && ![MIMEType isEqualToString:@"application/octet-stream"]) {
+ WebFileTypeMappings *mappings = [WebFileTypeMappings sharedMappings];
+ NSArray *extensions = [mappings extensionsForMIMEType:MIMEType];
+
+ if (![extension length] || (extensions && ![extensions containsObject:extension])) {
+ // The extension doesn't match the MIME type. Correct this.
+ NSString *correctExtension = [mappings preferredExtensionForMIMEType:MIMEType];
+ if ([correctExtension length] != 0) {
+ if ([extension length] != 0) {
+ // Remove the incorrect extension.
+ filename = [filename stringByDeletingPathExtension];
+ }
+
+ // Append the correct extension.
+ filename = [filename stringByAppendingPathExtension:correctExtension];
+ }
+ }
+ }
+
+ return filename;
+}
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 81459c0..5a5e9b8 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -297,6 +297,7 @@
511D5554033FD51000CA2ACD,
516F297003A6C45A00CA2D3A,
832B2D1603B10990009CF105,
+ 84A992C403CE696800CA2ACA,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -411,6 +412,7 @@
394460A5020F50ED0ECA1767,
394460A6020F50ED0ECA1767,
832B2D1703B10990009CF105,
+ 84A992C503CE696800CA2ACA,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -502,6 +504,8 @@
9345DDAF0365FB27008635CE,
832B2D1403B10990009CF105,
832B2D1503B10990009CF105,
+ 84A992C203CE696800CA2ACA,
+ 84A992C303CE696800CA2ACA,
F560BEBC030DAF4401C1A526,
F560BEBD030DAF4401C1A526,
F59668C802AD2923018635CA,
@@ -1902,6 +1906,33 @@
path = WebPluginViewFactory.h;
refType = 4;
};
+ 84A992C203CE696800CA2ACA = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ path = WebResourceResponseExtras.h;
+ refType = 4;
+ };
+ 84A992C303CE696800CA2ACA = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ path = WebResourceResponseExtras.m;
+ refType = 4;
+ };
+ 84A992C403CE696800CA2ACA = {
+ fileRef = 84A992C203CE696800CA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
+ 84A992C503CE696800CA2ACA = {
+ fileRef = 84A992C303CE696800CA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
84D4BFF70348EF7600CA2ACA = {
fileEncoding = 4;
isa = PBXFileReference;
diff --git a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
index 59b546b..ef5fada 100644
--- a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
@@ -122,8 +122,8 @@ typedef enum {
@param response The response for the partially loaded content.
@param request A WebResourceRequest for the partially loaded content.
*/
-- (NSString *)saveFilenameForResponse:(WebResourceResponse *)response
- andRequest:(WebResourceRequest *)request;
+- (NSString *)savePathForResponse:(WebResourceResponse *)response
+ andRequest:(WebResourceRequest *)request;
/*!
diff --git a/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m b/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
index 069305c..63a59e1 100644
--- a/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
@@ -49,8 +49,8 @@
}
}
-- (NSString *)saveFilenameForResponse:(WebResourceResponse *)response
- andRequest:(WebResourceRequest *)request
+- (NSString *)savePathForResponse:(WebResourceResponse *)response
+ andRequest:(WebResourceRequest *)request
{
return nil;
}
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 436d388..2142128 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -192,16 +192,15 @@
[dataSource _setIsDownloading:YES];
if ([dataSource downloadPath] == nil) {
- // FIXME: Should this be the filename or path?
- NSString *saveFilename = [[[dataSource controller] policyDelegate]
- saveFilenameForResponse:r andRequest:req];
+ NSString *savePath = [[[dataSource controller] policyDelegate]
+ savePathForResponse:r andRequest:req];
// FIXME: Maybe there a cleaner way handle the bad filename case?
- if(!saveFilename || [saveFilename length] == 0 || ![saveFilename isAbsolutePath]){
- ERROR("Nil or empty response to saveFilenameForResponse:andRequest:.");
+ if ([savePath length] == 0 || ![savePath isAbsolutePath]) {
+ ERROR("Nil, empty or non-absolute path returned from savePathForResponse:andRequest:.");
[self stopLoadingForPolicyChange];
return;
}
- [dataSource _setDownloadPath:saveFilename];
+ [dataSource _setDownloadPath:savePath];
}
[self interruptForPolicyChangeAndKeepLoading:YES];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 436d388..2142128 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -192,16 +192,15 @@
[dataSource _setIsDownloading:YES];
if ([dataSource downloadPath] == nil) {
- // FIXME: Should this be the filename or path?
- NSString *saveFilename = [[[dataSource controller] policyDelegate]
- saveFilenameForResponse:r andRequest:req];
+ NSString *savePath = [[[dataSource controller] policyDelegate]
+ savePathForResponse:r andRequest:req];
// FIXME: Maybe there a cleaner way handle the bad filename case?
- if(!saveFilename || [saveFilename length] == 0 || ![saveFilename isAbsolutePath]){
- ERROR("Nil or empty response to saveFilenameForResponse:andRequest:.");
+ if ([savePath length] == 0 || ![savePath isAbsolutePath]) {
+ ERROR("Nil, empty or non-absolute path returned from savePathForResponse:andRequest:.");
[self stopLoadingForPolicyChange];
return;
}
- [dataSource _setDownloadPath:saveFilename];
+ [dataSource _setDownloadPath:savePath];
}
[self interruptForPolicyChangeAndKeepLoading:YES];
diff --git a/WebKit/WebView.subproj/WebPolicyDelegate.h b/WebKit/WebView.subproj/WebPolicyDelegate.h
index 59b546b..ef5fada 100644
--- a/WebKit/WebView.subproj/WebPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebPolicyDelegate.h
@@ -122,8 +122,8 @@ typedef enum {
@param response The response for the partially loaded content.
@param request A WebResourceRequest for the partially loaded content.
*/
-- (NSString *)saveFilenameForResponse:(WebResourceResponse *)response
- andRequest:(WebResourceRequest *)request;
+- (NSString *)savePathForResponse:(WebResourceResponse *)response
+ andRequest:(WebResourceRequest *)request;
/*!
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list