Ada 4.1.1
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
idna.cc File Reference
#include <fuzzer/FuzzedDataProvider.h>
#include <memory>
#include <string>
#include "ada.cpp"
#include "ada.h"

Go to the source code of this file.

Functions

int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)

Function Documentation

◆ LLVMFuzzerTestOneInput()

int LLVMFuzzerTestOneInput ( const uint8_t * data,
size_t size )

High-level IDNA API

Round-trip property: to_unicode(to_ascii(x)) should not crash. We don't assert equality because IDNA may normalize/reject inputs.

Punycode functions

Unicode transcoding

IDNA label validation

IDNA mapping

Domain code point validation

Normalization

IDNA stability property.

Applying to_ascii twice must be idempotent: if to_ascii(x) produces a non-empty result, then to_ascii(to_ascii(x)) must equal to_ascii(x). A correctly normalised ACE label is already its own fixed point.

We allow the second call to return an empty string only if the first result was itself not a valid IDNA domain (some implementations return empty on failure). If the first result is non-empty and looks like a valid domain the second application must match.

to_unicode stability.

Applying to_unicode twice should also be idempotent: once a domain is in its Unicode presentation form, converting again should give the same result.

Long domain names near the DNS length limit (253 characters).

The IDNA and DNS-length checking code has special handling for domains close to or exceeding 253/255 characters and 63-character labels. Feed the fuzzer inputs of a controlled length to maximise coverage of those boundary checks.

Punycode round-trip on arbitrary binary blobs.

Feed random bytes directly into punycode_to_utf32, then if that succeeds encode the result back with utf32_to_punycode and verify the round-trip.

Definition at line 9 of file idna.cc.

References ada::idna::ascii_map(), ada::idna::contains_forbidden_domain_code_point(), ada::idna::is_ascii(), ada::idna::is_label_valid(), ada::idna::map(), ada::idna::normalize(), ada::idna::punycode_to_utf32(), ada::idna::to_ascii(), ada::idna::to_unicode(), ada::idna::utf32_length_from_utf8(), ada::idna::utf32_to_punycode(), ada::idna::utf32_to_utf8(), ada::idna::utf8_length_from_utf32(), ada::idna::utf8_to_utf32(), and ada::idna::verify_punycode().