| 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);
|
|
|