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

Unified Diff: third_party/WebKit/Source/core/html/parser/TextResourceDecoderFuzzer.cpp

Issue 2261873002: Add fuzzer for HTMLPreloadScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add include Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/TextResourceDecoderForFuzzing.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/TextResourceDecoderFuzzer.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoderFuzzer.cpp b/third_party/WebKit/Source/core/html/parser/TextResourceDecoderFuzzer.cpp
index e19011319fa1df5c8461662d7fcb9db30b769cce..b0e33faa3855650687074d7b3530ed6b7dace94e 100644
--- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoderFuzzer.cpp
+++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoderFuzzer.cpp
@@ -2,39 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/html/parser/TextResourceDecoder.h"
+#include "core/html/parser/TextResourceDecoderForFuzzing.h"
#include "platform/testing/FuzzedDataProvider.h"
#include "platform/testing/TestingPlatformSupport.h"
-#include "wtf/text/WTFString.h"
#include <algorithm>
namespace blink {
-class TextResourceDecoderForFuzzing : public TextResourceDecoder {
-public:
- // Note: mimeTypes can be quite long and still valid for XML. See the
- // comment in DOMImplementation.cpp which says:
- // Per RFCs 3023 and 2045, an XML MIME type is of the form:
- // ^[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+/[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]+\+xml$
- //
- // Similarly, charsets can be long too (see the various encodings in
- // wtf/text). For instance: "unicode-1-1-utf-8". To ensure good coverage,
- // set a generous max limit for these sizes (32 bytes should be good).
- TextResourceDecoderForFuzzing(FuzzedDataProvider& fuzzedData)
- : TextResourceDecoder(String::fromUTF8(fuzzedData.ConsumeBytesInRange(0, 32)), String::fromUTF8(fuzzedData.ConsumeBytesInRange(0, 32)), FuzzedOption(fuzzedData))
- {
- }
-
-private:
- static TextResourceDecoder::EncodingDetectionOption FuzzedOption(FuzzedDataProvider& fuzzedData)
- {
- // Don't use AlwaysUseUTF8ForText which requires knowing the mimeType
- // ahead of time.
- return fuzzedData.ConsumeBool() ? UseAllAutoDetection : UseContentAndBOMBasedDetection;
- }
-};
-
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
FuzzedDataProvider fuzzedData(data, size);
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/TextResourceDecoderForFuzzing.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698