Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Prevent js injection for non-200 response status codes #2

Merged
merged 4 commits into from
Mar 23, 2020

Conversation

danjm
Copy link
Collaborator

@danjm danjm commented Mar 4, 2020

Our logic for intercepting requests can result in an attempt to inject our js within text/html that comes with responses that have error codes. Also in cases where the body of the response is not actually text/html (perhaps this is something we should not be concerned with, but we also don't want to be enforcers of http standards). This can cause responses to requests from pages within our webview to be incorrectly modified, or to error without clear reason.

This PR ensures that we only intercept and inject JS into requests that are successful, have the content type: text/html header and actually contain some html in the body of the response.

@danjm danjm force-pushed the prevent-js-injection-of-error-response branch from 96571da to 28eff2e Compare March 17, 2020 14:56
@rekmarks rekmarks changed the title Prevent js injection for responses that contain 405 status codes Prevent js injection for non-200 response status codes Mar 17, 2020
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

See inline comment re: peekBody

@rekmarks rekmarks merged commit aeaf987 into master Mar 23, 2020
@rekmarks rekmarks deleted the prevent-js-injection-of-error-response branch March 23, 2020 19:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants