Changeset 56750 in webkit
- Timestamp:
- Mar 29, 2010 4:58:03 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56749 r56750 1 2010-03-29 Dawit Alemayehu <adawit@kde.org> 2 3 Reviewed by Simon Hausmann. 4 5 Added a function, WebCore::shouldTreatAsAttachment, to HTTPParsers.* 6 7 https://bugs.webkit.org/show_bug.cgi?id=36395 8 9 This function, which was moved from WebKit/chromium/src/FrameClientImpl.cpp, 10 is used to check whether or not a request is supposed to be rendered or 11 simply downloaded based on the "Content-Disposition" header sent by the 12 web server. The intent of code refactoring is to avoid code duplication 13 so that this piece of code can be used by other implementations such as 14 QtWebKit. 15 16 * platform/network/HTTPParsers.cpp: 17 (WebCore::shouldTreatAsAttachment): 18 * platform/network/HTTPParsers.h: 19 1 20 2010-03-29 Chris Fleizach <cfleizach@apple.com> 2 21 -
trunk/WebCore/platform/network/HTTPParsers.cpp
r56295 r56750 3 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 5 * Copyright (C) 2009 Google Inc. All rights reserved. 5 6 * 6 7 * Redistribution and use in source and binary forms, with or without … … 31 32 #include "config.h" 32 33 #include "HTTPParsers.h" 34 #include "ResourceResponseBase.h" 33 35 34 36 #include "CString.h" … … 69 71 70 72 return true; 73 } 74 75 bool shouldTreatAsAttachment(const ResourceResponseBase& response) 76 { 77 const String& contentDisposition = response.httpHeaderField("Content-Disposition"); 78 79 if (contentDisposition.isEmpty()) 80 return false; 81 82 // Some broken sites just send 83 // Content-Disposition: ; filename="file" 84 // screen those out here. 85 if (contentDisposition.startsWith(";")) 86 return false; 87 88 if (contentDisposition.startsWith("inline", false)) 89 return false; 90 91 // Some broken sites just send 92 // Content-Disposition: filename="file" 93 // without a disposition token... screen those out. 94 if (contentDisposition.startsWith("filename", false)) 95 return false; 96 97 // Also in use is Content-Disposition: name="file" 98 if (contentDisposition.startsWith("name", false)) 99 return false; 100 101 // We have a content-disposition of "attachment" or unknown. 102 // RFC 2183, section 2.8 says that an unknown disposition 103 // value should be treated as "attachment" 104 return true; 71 105 } 72 106 -
trunk/WebCore/platform/network/HTTPParsers.h
r56295 r56750 1 1 /* 2 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 33 34 34 35 class String; 36 class ResourceResponseBase; 35 37 36 38 enum XSSProtectionDisposition { … … 40 42 }; 41 43 44 45 bool shouldTreatAsAttachment(const ResourceResponseBase& response); 42 46 bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url); 43 47 double parseDate(const String&); -
trunk/WebKit/chromium/ChangeLog
r56728 r56750 1 2010-03-29 Dawit Alemayehu <adawit@kde.org> 2 3 Reviewed by Simon Hausmann. 4 5 Factored out the 'ShouldTreatAsAttachment' function to HTTPParsers.* 6 and replacted local version with the factored out version. 7 8 The code was factored out to make possible its use in other implementations 9 such as QtWebKit. 10 11 * src/FrameLoaderClientImpl.cpp: 12 (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForMIMEType): 13 1 14 2010-03-29 Jochen Eisinger <jochen@chromium.org> 2 15 -
trunk/WebKit/chromium/src/FrameLoaderClientImpl.cpp
r56346 r56750 39 39 #include "FrameLoader.h" 40 40 #include "FrameLoadRequest.h" 41 #include "HTTPParsers.h" 41 42 #include "HistoryItem.h" 42 43 #include "HitTestResult.h" … … 829 830 } 830 831 831 static bool shouldTreatAsAttachment(const ResourceResponse& response)832 {833 const String& contentDisposition =834 response.httpHeaderField("Content-Disposition");835 if (contentDisposition.isEmpty())836 return false;837 838 // Some broken sites just send839 // Content-Disposition: ; filename="file"840 // screen those out here.841 if (contentDisposition.startsWith(";"))842 return false;843 844 if (contentDisposition.startsWith("inline", false))845 return false;846 847 // Some broken sites just send848 // Content-Disposition: filename="file"849 // without a disposition token... screen those out.850 if (contentDisposition.startsWith("filename", false))851 return false;852 853 // Also in use is Content-Disposition: name="file"854 if (contentDisposition.startsWith("name", false))855 return false;856 857 // We have a content-disposition of "attachment" or unknown.858 // RFC 2183, section 2.8 says that an unknown disposition859 // value should be treated as "attachment"860 return true;861 }862 863 832 void FrameLoaderClientImpl::dispatchDecidePolicyForMIMEType( 864 833 FramePolicyFunction function, … … 875 844 // The server does not want us to replace the page contents. 876 845 action = PolicyIgnore; 877 } else if ( shouldTreatAsAttachment(response)) {846 } else if (WebCore::shouldTreatAsAttachment(response)) { 878 847 // The server wants us to download instead of replacing the page contents. 879 848 // Downloading is handled by the embedder, but we still get the initial -
trunk/WebKit/qt/Api/qwebpage.cpp
r56740 r56750 3559 3559 \fn void QWebPage::unsupportedContent(QNetworkReply *reply) 3560 3560 3561 This signal is emitted when WebKit cannot handle a link the user navigated to. 3561 This signal is emitted when WebKit cannot handle a link the user navigated to or a 3562 web server's response includes a "Content-Disposition" header with the 'attachment' 3563 directive. If "Content-Disposition" is present in \a reply, the web server is indicating 3564 that the client should prompt the user to save the content regardless of content-type. 3565 See RFC 2616 sections 19.5.1 for details about Content-Disposition. 3562 3566 3563 3567 At signal emission time the meta-data of the QNetworkReply \a reply is available. -
trunk/WebKit/qt/ChangeLog
r56740 r56750 1 2010-03-29 Dawit Alemayehu <adawit@kde.org> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] Added support for handling the HTTP "Content-Disposition" header. 6 7 https://bugs.webkit.org/show_bug.cgi?id=36395 8 9 Whenever a server response contains a "Content-Disposition: attachment..." header, 10 treat the request as a download and emit the unsupportedContent signal. 11 12 * Api/qwebpage.cpp: 13 * WebCoreSupport/FrameLoaderClientQt.cpp: 14 (WebCore::FrameLoaderClientQt::download): 15 (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForMIMEType): 16 1 17 2010-03-22 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 18 -
trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
r54938 r56750 51 51 #include "HTMLFormElement.h" 52 52 #include "HTMLPlugInElement.h" 53 #include "HTTPParsers.h" 53 54 #include "NotImplemented.h" 54 55 #include "QNetworkReplyHandler.h" … … 820 821 QWebPage *page = m_webFrame->page(); 821 822 if (page->forwardUnsupportedContent()) 822 emit m_webFrame->page()->unsupportedContent(reply);823 emit page->unsupportedContent(reply); 823 824 else 824 825 reply->abort(); … … 967 968 { 968 969 // we need to call directly here 969 if (canShowMIMEType(MIMEType)) 970 if (WebCore::shouldTreatAsAttachment(m_frame->loader()->activeDocumentLoader()->response())) 971 callPolicyFunction(function, PolicyDownload); 972 else if (canShowMIMEType(MIMEType)) 970 973 callPolicyFunction(function, PolicyUse); 971 974 else
Note: See TracChangeset
for help on using the changeset viewer.