Accept Utf16View patterns at the LibRegex compile boundary and pass UTF-16 or ASCII storage directly into the Rust regex parser. This keeps JavaScript regular expression construction from converting patterns through UTF-8 when LibRegex can consume the same UTF-16 representation used by LibJS. Update RegExp construction, HTML pattern validation, the regex fuzzer, and LibRegex tests to use the UTF-16 compile API.
19 lines
579 B
C++
19 lines
579 B
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringView.h>
|
|
#include <AK/Utf16String.h>
|
|
#include <LibRegex/ECMAScriptRegex.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
|
{
|
|
AK::set_debug_enabled(false);
|
|
auto pattern = Utf16String::from_utf8_with_replacement_character(StringView(static_cast<unsigned char const*>(data), size));
|
|
[[maybe_unused]] auto re = regex::ECMAScriptRegex::compile(pattern.utf16_view(), {});
|
|
return 0;
|
|
}
|