diff --git a/projects/ftfy/fuzz_fix.py b/projects/ftfy/fuzz_fix.py index 6476959a7..c1503f7d1 100644 --- a/projects/ftfy/fuzz_fix.py +++ b/projects/ftfy/fuzz_fix.py @@ -22,28 +22,19 @@ def TestInput(data): fdp = atheris.FuzzedDataProvider(data) try: - ftfy.fix_text(fdp.ConsumeString(1000)) - ftfy.fix_text(fdp.ConsumeUnicode(1000)) - - plan1 = ftfy.fix_and_explain(fdp.ConsumeString(1000))[1] - plan2 = ftfy.fix_and_explain(fdp.ConsumeUnicode(1000))[1] - ftfy.apply_plan(fdp.ConsumeString(1000), plan1) - ftfy.apply_plan(fdp.ConsumeString(1000), plan2) - ftfy.apply_plan(fdp.ConsumeUnicode(1000), plan1) - ftfy.apply_plan(fdp.ConsumeUnicode(1000), plan2) - - ftfy.fix_text_segment(fdp.ConsumeString(1000)) - ftfy.fix_text_segment(fdp.ConsumeUnicode(1000)) + ftfy.fix_text(fdp.ConsumeUnicodeNoSurrogates(100)) + plan1 = ftfy.fix_and_explain(fdp.ConsumeUnicodeNoSurrogates(100))[1] + ftfy.apply_plan(fdp.ConsumeUnicodeNoSurrogates(100), plan1) + ftfy.fix_text_segment(fdp.ConsumeUnicodeNoSurrogates(100)) f = open("temp.txt", "w") - f.write(fdp.ConsumeString(1000)) - f.write(fdp.ConsumeUnicode(1000)) + f.write(fdp.ConsumeUnicodeNoSurrogates(1000)) f.close() f = open("temp.txt", "r") ftfy.fix_file(f) f.close() - ftfy.guess_bytes(fdp.ConsumeBytes(1000)) + ftfy.guess_bytes(fdp.ConsumeBytes(100)) except UnicodeError as e: if "Hey wait, this isn't Unicode." not in str(e): raise e diff --git a/projects/ftfy/fuzz_format.py b/projects/ftfy/fuzz_format.py index 1447cc85c..321cea462 100644 --- a/projects/ftfy/fuzz_format.py +++ b/projects/ftfy/fuzz_format.py @@ -26,22 +26,16 @@ def TestInput(data): fdp = atheris.FuzzedDataProvider(data) ftfy.character_width(chr(fdp.ConsumeIntInRange(1,1114110))) - ftfy.monospaced_width(fdp.ConsumeString(1000)) - ftfy.monospaced_width(fdp.ConsumeUnicode(1000)) + ftfy.monospaced_width(fdp.ConsumeUnicodeNoSurrogates(1000)) choice = fdp.ConsumeIntInRange(1,3) if choice == 1: - ftfy.display_ljust(fdp.ConsumeString(1000),fdp.ConsumeIntInRange(1,2000)) - ftfy.display_ljust(fdp.ConsumeUnicode(1000),fdp.ConsumeIntInRange(1,2000)) + ftfy.display_ljust(fdp.ConsumeUnicodeNoSurrogates(1000),fdp.ConsumeIntInRange(1,2000)) if choice == 2: - ftfy.display_rjust(fdp.ConsumeString(1000),fdp.ConsumeIntInRange(1,2000)) - ftfy.display_rjust(fdp.ConsumeUnicode(1000),fdp.ConsumeIntInRange(1,2000)) + ftfy.display_rjust(fdp.ConsumeUnicodeNoSurrogates(1000),fdp.ConsumeIntInRange(1,2000)) if choice == 3: - ftfy.display_center(fdp.ConsumeString(1000),fdp.ConsumeIntInRange(1,2000)) - ftfy.display_center(fdp.ConsumeUnicode(1000),fdp.ConsumeIntInRange(1,2000)) - - fixes.remove_bom(fdp.ConsumeString(1000)) - fixes.remove_bom(fdp.ConsumeUnicode(1000)) + ftfy.display_center(fdp.ConsumeUnicodeNoSurrogates(1000),fdp.ConsumeIntInRange(1,2000)) + fixes.remove_bom(fdp.ConsumeUnicodeNoSurrogates(1000)) def main(): atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)