Skip to content

Unescape pre-flight response when uploading plugin#2072

Merged
AlexTugarev merged 1 commit intogitpod-io:masterfrom
jgallucci32:patch-2
Nov 4, 2020
Merged

Unescape pre-flight response when uploading plugin#2072
AlexTugarev merged 1 commit intogitpod-io:masterfrom
jgallucci32:patch-2

Conversation

@jgallucci32
Copy link
Contributor

Fixes issue where the response URI for uploading plugins is unescaped which generates a "400 Bad Request" error when uploading to Minio.

Closes #2067

@jgallucci32 jgallucci32 changed the title Escape pre-flight response when uploading plugin Unescape pre-flight response when uploading plugin Oct 27, 2020
@AlexTugarev AlexTugarev self-requested a review October 28, 2020 08:56
@AlexTugarev
Copy link
Member

AlexTugarev commented Oct 28, 2020

@jgallucci32 your PR is appreciated! Thanks a lot.

Please would you like to change the solution to not encode in the server component, so that decoding is no longer required in the proxy. 🙏

encodeURI is to be removed from https://github.com/gitpod-io/gitpod/blob/master/components/server/src/theia-plugin/theia-plugin-controller.ts#L57 instead of decoding in the proxy, simply because we don't need to do that in the server if it need to be reverted in the proxy anyways.

Thanks to @corneliusludmann! he just pointed out, that the explanation wasn't clear enough.

@jgallucci32
Copy link
Contributor Author

@AlexTugarev Yes I will do that, thank you for pointing out how it was encoded in the first place. After doing some reading I am in agreement. Apparently using encodingURI programmatically is discouraged and discussed in a few places as why it should be avoided.

Unfortunately, encodeURI has a critical flaw, which is that it escapes '%' characters, making it completely useless for URI cleaning (it will double-escape any URI that already had percent-escapes).

Reference: https://stackoverflow.com/questions/9245333/should-encodeuri-ever-be-used/9245778

Fixes issue where the response URI for uploading plugins is double-encoded which generates a "400 Bad Request" error when uploading to Minio.

Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
@AlexTugarev
Copy link
Member

AlexTugarev commented Nov 4, 2020

/werft run

👍 started the job as gitpod-build-patch-2.0

Copy link
Member

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

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

Code looks good, let's have a test ride and merge!

@AlexTugarev
Copy link
Member

AlexTugarev commented Nov 4, 2020

https://werft.gitpod-dev.com/job/gitpod-build-patch-2.0 is green.
'just tested that upload works as expected.

@jgallucci32 thank you very much for you contribution 🎉

@AlexTugarev AlexTugarev merged commit 24f49d0 into gitpod-io:master Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm chart minio bug + extension upload bug

3 participants