Any disposition that's not "inline" should be treated as "attachment".

Bug 172003, r=bbaetz, sr=rpotts


git-svn-id: svn://10.0.0.236/trunk@133765 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2002-11-13 21:17:40 +00:00
parent 73d20cd728
commit a90238e37d
2 changed files with 39 additions and 13 deletions

View File

@ -317,17 +317,30 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
++start;
}
nsCAutoString::const_iterator iter = start;
// walk forward till we hit the next whitespace or semicolon
while (iter != end && *iter != ';' && !nsCRT::IsAsciiSpace(*iter))
// walk forward till we hit the next whitespace, semicolon, or
// equals sign
while (iter != end && *iter != ';' && *iter != '=' &&
!nsCRT::IsAsciiSpace(*iter))
{
++iter;
}
if (start != iter &&
Substring(start, iter).Equals(NS_LITERAL_CSTRING("attachment"),
nsCaseInsensitiveCStringComparator()))
if (start != iter)
{
// We have a content-disposition of "attachment"
forceExternalHandling = PR_TRUE;
const nsACString & dispToken = Substring(start, iter);
// RFC 2183, section 2.8 says that an unknown disposition
// value should be treated as "attachment"
if (!dispToken.Equals(NS_LITERAL_CSTRING("inline"),
nsCaseInsensitiveCStringComparator()) &&
// Broken sites just send
// Content-Disposition: filename="file"
// without a disposition token... screen those out.
!dispToken.Equals(NS_LITERAL_CSTRING("filename"),
nsCaseInsensitiveCStringComparator()))
{
// We have a content-disposition of "attachment" or unknown
forceExternalHandling = PR_TRUE;
}
}
}

View File

@ -885,14 +885,27 @@ void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel* aChan
++start;
}
nsCAutoString::const_iterator iter = start;
// walk forward till we hit the next whitespace or semicolon
while (iter != end && *iter != ';' && !nsCRT::IsAsciiSpace(*iter)) {
// walk forward till we hit the next whitespace, semicolon, or
// equals sign
while (iter != end && *iter != ';' && *iter != '=' &&
!nsCRT::IsAsciiSpace(*iter)) {
++iter;
}
if (start != iter &&
Substring(start, iter).Equals(NS_LITERAL_CSTRING("attachment"),
nsCaseInsensitiveCStringComparator())) {
mHandlingAttachment = PR_TRUE;
if (start != iter) {
const nsACString & dispToken = Substring(start, iter);
// RFC 2183, section 2.8 says that an unknown disposition
// value should be treated as "attachment"
if (!dispToken.Equals(NS_LITERAL_CSTRING("inline"),
nsCaseInsensitiveCStringComparator()) &&
// Broken sites just send
// Content-Disposition: filename="file"
// without a disposition token... screen those out.
!dispToken.Equals(NS_LITERAL_CSTRING("filename"),
nsCaseInsensitiveCStringComparator())) {
// We have a content-disposition of "attachment" or unknown
mHandlingAttachment = PR_TRUE;
}
}
// We may not have a disposition type listed; some servers suck.