Skip to content

consider specifying encoding in calls to open #16

Description

@michaelmera

When no encoding is specified, the actual encoding used is platform dependent. This means that if you prepare example files for a reviewer, he might not be able to run the code on his machine.

Note however that reviewers might have then a problem if they prepare files with a different encoding than the one you specified.

PyGlade/src/glade.py

Lines 787 to 818 in dcf503d

with open('inputs') as f:
inputs = [line.strip() for line in f]
if len(inputs) == 0:
print("inputs file is empty! Please provide inputs.")
sys.exit()
for input_str in inputs:
regexes.append(phase_1([i for i in input_str]))
print("One regex done")
print("\n+++++ Phase 1 Done +++++\n")
# Combine regexes into one regex as explained in Section 6.1
regex = regexes[0]
regexes.pop(0)
for reg in regexes:
regex = Alt(regex, reg, False)
print("Final regex: " + str(regex))
cfg, start = phase_2(regex)
with open('grammar_.json', 'w+') as f:
json.dump({'<start>': [[start]], **cfg}, indent=4, fp=f)
print('\n+++++ Merging Phase Begins +++++\n')
merged = phase_3(cfg, start)
# Save the final grammar in the fuzzing book format
with open('grammar.json', 'w+') as f:
json.dump({'<start>': [[start]], **merged}, indent=4, fp=f)

with open(fn) as f:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions