-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix(form-v2): update CSP and image URL computation to use the correct URL #4483
Conversation
…ect url. remove blob from script to test if works
As is, everything works as intended. However, the browser console does complain about the I don't seem to be able to find any reference to Tagging @timotheeg for thoughts! Screen.Recording.2022-08-03.at.3.53.05.PM.mov |
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.
It's also unclear to me why blob shows up in a script-src warning. If we cannot find it in source, let's do some markup inspection. Call me and we can pair on it!
@@ -117,7 +117,7 @@ const uploadFile = async ({ | |||
// POST generated formData to presigned url. | |||
const response = await postToPresignedUrl(postData.url, formData) | |||
|
|||
const encodedFileId = encodeURIComponent(fileId) | |||
const encodedFileId = encodeURIComponent(postData.fields.key) |
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.
encodedFileId
is concatenated straight into a url below, so just to clarify, what format do we expect postData.fields.key
to have? I'm asking to because we have to be careful that meaningful url characters (e.g. /
) are not encoded.
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.
The fileId
is the input file ID, but the controller itself returns a new file ID because we randomized the fileID in the controller here, which instituted a change to the file handler in angular and we need need to replicate this behavior in react
Problem
Image and logo uploads in general are not working in both the preview and saved mode. This occurs for two different reasons:
blob:
s. However the browser refuses to load these becauseblob:
s are not allowed in our CSP.uploadFile
.Closes #4360
Solution
blob:
to ourimgSrc
CSP.uploadFile
to use the correct source for the uploaded file ID.See also:
https://stackoverflow.com/questions/28467789/content-security-policy-object-src-blob
https://csplite.com/csp105/#:~:text=The%20Content%20Security%20Policy%20controls,from%20the%20blob%3A-URI.
https://content-security-policy.com/#source_list
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
Breaking Changes
Screenshots
See comment below :)