Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix payload string generation #17

Merged
merged 1 commit into from
May 5, 2024

Conversation

ivanpuchalka
Copy link
Contributor

Fixes #10.

To ensure the generated string is a valid Python literal, this new code manually creates an instance of an AST constant node with the value parsed from the HAR and then uses ast.unparse.

A few details worth reviewing:

  • The literal generation is implemented as an entriesprocessor_with_args defined in the main module, I don't think it fits as a plugin because it needs to be executed for the program to work properly.

  • Since the output now includes the enclosing quotes, I removed them from the default template.

  • With the changes, the apple-buy-a-mac test started to fail. It seems the test was wrong: the expected output ignored backslashes that should be in the string, but got interpreted as part of a double quote escape sequence. It's now changed to reflect the correct expected output (and correct behaviour).

@cyberw cyberw merged commit fb31f98 into SvenskaSpel:main May 5, 2024
5 checks passed
@cyberw
Copy link
Collaborator

cyberw commented May 5, 2024

Thanks!

@cyberw
Copy link
Collaborator

cyberw commented May 5, 2024

The tests break when there are changes in the output, they are a bit weird in that way, but it is by design. There’s a make action to update them. I uses the git diff in the generated output to validate that any changes were good :)

@ivanpuchalka ivanpuchalka deleted the body-string-literals branch May 5, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error parsing har file
2 participants