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

refactor: use res.json if backwards compatible with client #426

Merged
merged 8 commits into from
Oct 8, 2020

Conversation

mantariksh
Copy link
Contributor

Problem

Usage of res.send creates the risk of HTML injection attacks if not used with care. Using res.json is better practice.

Solution

This PR addresses the cases where changing from res.status to res.json is compatible with the client.
When the client does not use the content of the response body, it is safe to change res.send to res.json, wrapping the original string in an object. For example, the client sometimes does its own success/error handling, or simply logs errors to the console. This applies to the following API endpoints:

  • GET /billing
  • POST /:formId/adminform/feedback
  • POST /:formId/feedback
  • GET /spcp/redirect
  • GET /spcp/validate
  • GET /auth/signout
  • GET /user
  • Generic error handling for celebrate errors

@mantariksh mantariksh requested a review from tshuli October 7, 2020 07:38
Base automatically changed from refactor/res-json to develop October 7, 2020 09:31
@liangyuanruo liangyuanruo merged commit 5edb9af into develop Oct 8, 2020
@liangyuanruo liangyuanruo deleted the refactor/res-json-2 branch October 8, 2020 02:32
@karrui karrui mentioned this pull request Oct 8, 2020
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