Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Unified Diff: third_party/WebKit/Source/platform/network/ContentHeaderFieldInput.h

Issue 2880543003: Implement a parser for Content-Disposition header fields (Closed)
Patch Set: Inheritance to delegation, tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/network/ContentHeaderFieldInput.h
diff --git a/third_party/WebKit/Source/platform/network/ParsedContentType.h b/third_party/WebKit/Source/platform/network/ContentHeaderFieldInput.h
similarity index 54%
copy from third_party/WebKit/Source/platform/network/ParsedContentType.h
copy to third_party/WebKit/Source/platform/network/ContentHeaderFieldInput.h
index a014b6df29e96afdd1f980bc9a05e4d54e79c728..8427a999f2094a684df275c85e40dfbe7478413e 100644
--- a/third_party/WebKit/Source/platform/network/ParsedContentType.h
+++ b/third_party/WebKit/Source/platform/network/ContentHeaderFieldInput.h
@@ -29,55 +29,35 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ParsedContentType_h
-#define ParsedContentType_h
+#ifndef ContentHeaderFieldInput_h
+#define ContentHeaderFieldInput_h
-#include "platform/PlatformExport.h"
-#include "platform/wtf/Allocator.h"
-#include "platform/wtf/HashMap.h"
-#include "platform/wtf/text/StringHash.h"
+#include "platform/network/ParsedContentHeaderFieldParameters.h"
+#include "platform/wtf/text/WTFString.h"
namespace blink {
-// ParsedContentType parses the constructor argument as specified in RFC2045
-// and stores the result.
-// FIXME: add support for comments.
-class PLATFORM_EXPORT ParsedContentType final {
+class ContentHeaderFieldInput final {
STACK_ALLOCATED();
public:
- // When |Relaxed| is specified, the parser parses parameter values in a sloppy
- // manner, i.e., only ';' and '"' are treated as special characters.
- // See https://chromiumcodereview.appspot.com/23043002.
- // When |Strict| is specified, the parser does not allow multiple values
- // for the same parameter. Some RFCs based on RFC2045 (e.g. RFC6838) note that
- // "It is an error for a specific parameter to be specified more than once."
- enum class Mode {
- kNormal,
- kRelaxed,
- kStrict,
- };
- explicit ParsedContentType(const String&, Mode = Mode::kNormal);
+ using Mode = ParsedContentHeaderFieldParameters::Mode;
- String MimeType() const { return mime_type_; }
- String Charset() const;
+ explicit ContentHeaderFieldInput(const String& header_field);
+ ContentHeaderFieldInput(ContentHeaderFieldInput&&);
- // Note that in the case of multiple values for the same name, the last value
- // is returned.
- String ParameterValueForName(const String&) const;
- size_t ParameterCount() const;
-
- bool IsValid() const { return is_valid_; }
+ bool Consume(char);
+ bool ConsumeToken(Mode, StringView& output);
+ bool ConsumeTokenOrQuotedString(Mode, String& output);
+ unsigned Index() const { return index_; }
+ bool IsConsumed() const { return index_ >= input_.length(); }
+ void SkipSpaces();
private:
- bool Parse(const String&);
-
- const Mode mode_;
- bool is_valid_;
+ bool ConsumeQuotedString(String& output);
- typedef HashMap<String, String> KeyValuePairs;
- KeyValuePairs parameters_;
- String mime_type_;
+ unsigned index_;
+ const String input_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698