Skip to content

Commit

Permalink
updating with some fixes for none strings
Browse files Browse the repository at this point in the history
  • Loading branch information
katharine authored and katharine committed Mar 29, 2023
1 parent 29c0a72 commit 4abf81c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions datafuzz/utils/fuzz_helpers.py
Expand Up @@ -19,20 +19,24 @@

def add_format(val):
""" Insert format strings """
if val is None:
val = ""
idx = random.randint(0, len(val))
format_str = '%{}'.format(random.choice(list('fdsr')))
return val[:idx] + format_str + val[idx:]


def change_encoding(val):
""" Return byte value with perhaps bad encoding """
if val is None:
val = ""
choice = random.choice(
['utf-16', 'latin-1', 'windows-1250', 'iso-8859-1'])
return val.encode(choice, errors='replace')


def to_bytes(val):
""" Return byte value """
if val is None:
val = ""
return bytes(val, encoding='utf-8')


Expand Down

0 comments on commit 4abf81c

Please sign in to comment.