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

Comments posted on a pending review get extra quote wrapping #118

Closed
joestringer opened this issue Jul 9, 2024 · 6 comments · Fixed by #120
Closed

Comments posted on a pending review get extra quote wrapping #118

joestringer opened this issue Jul 9, 2024 · 6 comments · Fixed by #120

Comments

@joestringer
Copy link
Contributor

joestringer commented Jul 9, 2024

If you start a pending review, then use GHCreateThread and post a comment onto some code, the output in the target PR looks like:

'
This is the message in the review comment. Any '\''apostraphe'\'' comes out looking like this.
'

What I would expect to see is the verbatim comment:

This is the message in the review comment. Any 'apostraphe' comes out looking like this.

The same issue also occurs when submitting a review with a top-level comment.

@joestringer
Copy link
Contributor Author

joestringer commented Jul 9, 2024

Not really obvious to me how this code ends up with that result:

string.format("body=%s", body),

This didn't previously happen on a much earlier version of gh.nvim, so I'm not sure if this is related to my gh tool version or something in the libraries here that has changed.

For reference:

$ gh --version
gh version 2.52.0 (2024-06-24)
https://github.com/cli/cli/releases/tag/v2.52.0

@joestringer
Copy link
Contributor Author

For reference the input is already malformed before it gets into gh CLI:

Enabled debug_logging in the config:

require('litee.gh').setup({debug_logging = true})

Then submitted a new comment with the value test a new reply and opened GHOpenDebugBuffer. We already see the extra quotes here:

[info] [gh] cmd: { "gh", "api", "graphql", "-F", "pull=...", "-F", "review=...", "-F", "commit=...", "-F", "body='test a new reply'", ...

@joestringer
Copy link
Contributor Author

Oh that would do it:

body = vim.fn.shellescape(body)

@rmacklin
Copy link

rmacklin commented Jul 10, 2024

I'm unable to look deeply at the moment, but might it be related to d6afb4f (the same commit you linked to in #117)? Seems like some gh commands were changed from strings (which included gh itself) to lists (with just the args after gh), so perhaps there was some escaping that was needed before that commit which is no longer needed.

Edit: looks like you found it and replied while I was replying.

@joestringer
Copy link
Contributor Author

@rmacklin ha, indeed it looks like we found it at the same time. I've posted a PR with the proposal. I didn't vet whether there are any other callers that might still need the escaping, so let me know if there's anything I missed there. Should fix it though.

@rmacklin
Copy link

rmacklin commented Jul 10, 2024

There may be similar extra escaping happening in the other extract_text methods for commits/issues:

body = vim.fn.shellescape(body)

body = vim.fn.shellescape(body)

and possibly in pull request review submission comments:
body = vim.fn.shellescape(body)

body = vim.fn.shellescape(body)

but I'm unable to test currently.

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 a pull request may close this issue.

2 participants