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

Make sure quotes in json are escaped #2880

Closed
wants to merge 1 commit into from

Conversation

iainbeeston
Copy link

Why

I'm seeing issues when I run eas build:list --json because git commit messages are included in the result but git commit messages sometimes contain quotes. These aren't escaped and so I am seeing invalid json in the output that looks like this:

{
\\...
"gitCommitMessage": "Changed some "stuff""
}

How

I've changed this so that string values (only) are escaped using JSON.stringify.

Test Plan

I'd love to include tests for this but I couldn't see an appropriate test file to add them to. Considering that I would test this like this:

  1. Create a build for a commit that contains a commit message with double quotes in it
  2. Run eas build:list --json --non-interactive and confirm that the gitCommitMessage is there but has the double quotes escaped
  3. Try parsing the json using jq '.[]' to confirm that it's valid json (the json should be output by jq and there should be no parsing error

Copy link

github-actions bot commented Feb 5, 2025

Subscribed to pull request

File Patterns Mentions
**/* @szdziedzic, @khamilowicz, @sjchmiela, @radoslawkrzemien

Generated by CodeMention

I'm seeing issues when I run `eas build:list --json` because git commit messages are included in the result but git commit messages sometimes contain quotes. These aren't escaped and so I am seeing invalid json in the output that looks like this:

```
{
\\...
"gitCommitMessage": "Changed some "stuff""
}
```

I've changed this so that string values (only) are escaped using `JSON.stringify`.
Copy link
Member

@szdziedzic szdziedzic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I believe the output from sanitizeValue is already passed to JSON.stringify:

Log.log(JSON.stringify(sanitizeValue(value), null, 2));

I run eas build:list --json --non-interactive and I checked it worked for me just fine:
Screenshot 2025-02-06 at 16 18 10

Can you share more details about how you were able to see this issue?

@iainbeeston
Copy link
Author

Thanks @szdziedzic - you're right. I'm calling eas:build list in a script and it looks like something else must be messing with the json. I'm closing this as I don't think there is an issue.

@iainbeeston iainbeeston closed this Feb 6, 2025
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.

2 participants