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

Error messages should be escaped #24

Closed
tuukkamustonen opened this issue Oct 25, 2016 · 2 comments
Closed

Error messages should be escaped #24

tuukkamustonen opened this issue Oct 25, 2016 · 2 comments

Comments

@tuukkamustonen
Copy link

tuukkamustonen commented Oct 25, 2016

Publishing comments failed, because plugin doesn't escape error message content and Stash attempts to interpret \ prefixed characters . For example, comment:

Found 1 violation:
Reporter: PYLINT
Rule: anomalous-backslash-in-string
Severity: WARN
File: fs/csm/admin_api/admin_api.py L1086

Anomalous backslash in string: '\s'. String constant might be missing an r prefix.
<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>

Gets POSTed as:

$ curl -u user:pass -X POST -H 'Content-Type: application/json' -d "{\"text\": \"Found 1 violation:\n\nReporter: PYLINT\nRule: anomalous-backslash-in-string\nSeverity: WARN\nFile: fs/csm/admin_api/auth.py L52\n \n\nAnomalous backslash in string: '\.'. String constant might be missing an r prefix.\n\n<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>\"}" https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments

{"errors":[{"context":null,"message":"Unrecognized character escape 's' (code 115)\n at [Source: com.atlassian.stash.internal.web.util.web.CountingServletInputStream@31131921; line: 1, column: 186]","exceptionName":"org.codehaus.jackson.JsonParseException"}]}root@a53ac6de14b0:/# 

Adding double escaping (from shell) works:

$ curl -u user:pass -X POST -H 'Content-Type: application/json' -d "{\"text\": \"Found 1 violation:\n\nReporter: PYLINT\nRule: anomalous-backslash-in-string\nSesm/admin_api/admin_api.py L1086\n \n\nAnomalous backslash in string: '\\\s'. String constant might be missing an r prefix.\n\n<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>\"}" https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments

{"properties":{"repositoryId":713},"id":121713,"version":0,"text":"Found 1 violation:\n\nReporter: PYLINT\nRule: anomalous-backslash-in-string\nSeverity: WARN\nFile: fs/csm/admin_api/admin_api.py L1086\n \n\nAnomalous backslash in string: '\\s'. String constant might be missing an r prefix.\n\n<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>","author":{"name":"rd-team-essentials-s","emailAddress":"","id":4763,"displayName":"rd-team-essentials-s","active":true,"slug":"rd-team-essentials-s","type":"NORMAL","links":{"self":[{"href":"https://mystash.gtn/users/rd-team-essentials-s"}]}},"createdDate":1477403666741,"updatedDate":1477403666741,"comments":[],"tasks":[],"permittedOperations":{"editable":true,"deletable":true}}
@tomasbjerre
Copy link
Contributor

Should be fixed in 1.31

@tomasbjerre
Copy link
Contributor

Open issue again if not fixed!

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

No branches or pull requests

2 participants