def quote_field_if_needed(field_data: bytes, quotechar: bytes, delimiter: bytes) -> bytes:
    """
    quote the field if quote character or delimiter is within the field

    >>> quote_field_if_needed(b'test', quotechar=b'"', delimiter=b';')
    b'test'
    >>> quote_field_if_needed(b'te""st', quotechar=b'"', delimiter=b';')
    b'"te""st"'
    >>> quote_field_if_needed(b'te;st', quotechar=b'"', delimiter=b';')
    b'"te;st"'
    """

    if quotechar in field_data or delimiter in field_data:
        field_data = quotechar + field_data + quotechar
    return field_data