diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:06:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:31:31 (GMT) |
commit | c411f16870f112c3407c28c22b617f613a82cff4 (patch) | |
tree | 29a1bcd590c8b31af2aab445bfe8a978dc5bf582 /src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp | |
parent | 3d77b56b32a0c53ec0bbfaa07236fedb900ff336 (diff) | |
download | Qt-c411f16870f112c3407c28c22b617f613a82cff4.zip Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.gz Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.bz2 |
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-15062009 ( 65232bf00dc494ebfd978f998c88f58d18ecce1e )
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp b/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp index 0858fc9..ad65dfe 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,12 +40,13 @@ static inline bool skipWhiteSpace(const String& str, int& pos, bool fromHttpEqui { int len = str.length(); - if (fromHttpEquivMeta) + if (fromHttpEquivMeta) { while (pos != len && str[pos] <= ' ') ++pos; - else + } else { while (pos != len && (str[pos] == '\t' || str[pos] == ' ')) ++pos; + } return pos != len; } @@ -131,18 +133,37 @@ String filenameFromHTTPContentDisposition(const String& value) String extractMIMETypeFromMediaType(const String& mediaType) { - String mimeType; + Vector<UChar, 64> mimeType; unsigned length = mediaType.length(); - for (unsigned offset = 0; offset < length; offset++) { - UChar c = mediaType[offset]; + mimeType.reserveCapacity(length); + for (unsigned i = 0; i < length; i++) { + UChar c = mediaType[i]; + if (c == ';') break; - else if (isSpaceOrNewline(c)) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045. bug 8644 + + // While RFC 2616 does not allow it, other browsers allow multiple values in the HTTP media + // type header field, Content-Type. In such cases, the media type string passed here may contain + // the multiple values separated by commas. For now, this code ignores text after the first comma, + // which prevents it from simply failing to parse such types altogether. Later for better + // compatibility we could consider using the first or last valid MIME type instead. + // See https://bugs.webkit.org/show_bug.cgi?id=25352 for more discussion. + if (c == ',') + break; + + // FIXME: The following is not correct. RFC 2616 allows linear white space before and + // after the MIME type, but not within the MIME type itself. And linear white space + // includes only a few specific ASCII characters; a small subset of isSpaceOrNewline. + // See https://bugs.webkit.org/show_bug.cgi?id=8644 for a bug tracking part of this. + if (isSpaceOrNewline(c)) continue; - // FIXME: This is a very slow way to build a string, given WebCore::String's implementation. - mimeType += String(&c, 1); + + mimeType.append(c); } - return mimeType; + + if (mimeType.size() == length) + return mediaType; + return String(mimeType.data(), mimeType.size()); } String extractCharsetFromMediaType(const String& mediaType) |