-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ipfs get: set correct content-type on resp #2004
Conversation
License: MIT Signed-off-by: rht <[email protected]>
mmm... i see you PRing against master... i'll allow this one though. fairly trivial. LGTM |
@@ -232,7 +234,9 @@ func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req | |||
if _, ok := res.Output().(io.Reader); ok { | |||
// set streams output type to text to avoid issues with browsers rendering | |||
// html pages on priveleged api ports | |||
mime = "text/plain" | |||
if mime != mimeTypes[cmds.Tar] && mime != mimeTypes[cmds.Gzip] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe can make it something like:
if !xssSafeMimeType(mime) {
mime = mimeTypes[cmds.Text]
}
and elsewhere something like:
var xssSafeMimeTypes = []string{
mimeTypes[cmds.Tar],
mimeTypes[cmds.GZip],
mimeTypes[cmds.Text],
mimeTypes[cmds.JSON],
}
func xssSafeMimeType(mime string) {
for _, t := range xssSafeMimeTypes {
if t == mime {
return true
}
}
return false
}
to make it clear why this is happening, and easier to broaden the safety boundary, in a single place.
this probably could be a separate package, and may already exist somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No such package exists elsewhere yet.
one comment above, otherwise LGTM |
@rht update here? |
@rht doesn't have commit access |
This is a version of #2004, with CR from @jbenet integrated in, and should close #1824 License: MIT Signed-off-by: Richard Littauer <[email protected]>
This is a version of #2004, with CR from @jbenet integrated in, and should close #1824 License: MIT Signed-off-by: Richard Littauer <[email protected]>
closes #1824