fix: use correct SVG data format for autogenerated zones#518
Conversation
This fixes content type recognition in Chrome 146.
|
Thanks for the pull request, @Agrendalath! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
|
Thanks for the pull request, @Agrendalath! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
| if (Object.keys(params).length > 0) { | ||
| return params; | ||
| } | ||
| // Legacy format: params encoded in the MIME type section of the data URI. |
There was a problem hiding this comment.
I kept it for the editor's compatibility with the previous format. I could have used the converted URI from the backend here, but I wanted to avoid potential side effects, since this editor is quite complex.
| var autozone_data = _fn.build.form.zone.calculateAutozoneData(params); | ||
| var svg = _fn.tpl.autozoneSvg(autozone_data).trim(); | ||
| var data_uri_params = _fn.build.encodeDataUriParams({ | ||
| producer: 'dndv2', |
There was a problem hiding this comment.
I hardcoded the producer in the autozone-tpl, since it never changes.
| 'fields': self.fields, | ||
| 'showanswer_set': self._field_data.has(self, 'showanswer'), # If false, we're using an inherited value. | ||
| 'self': self, | ||
| 'data': six.moves.urllib.parse.quote(json.dumps(self.data)), |
There was a problem hiding this comment.
This is not directly related, but I wanted to ensure that we do not use this data anywhere in the editor.
| if not match: | ||
| return data_uri |
There was a problem hiding this comment.
This should never happen, but I have added it as a failsafe.
|
Thanks! |
This fixes content type recognition in Chrome 146, caused by https://developer.chrome.com/release-notes/146#data_url_mime_type_parameter_preservation.
Description
This moves SVG metadata from MIME type parameters to the SVG node's data attributes. This way, the content is correctly recognized by Chrome 146.
Testing instructions
Deadline
"None", but it would be nice to fix it sooner rather than later, since it affects all instances.
Other information
Related discussion: https://discuss.openedx.org/t/chrome-version-146-0-x-breaks-on-svg-automatic-generation-for-drag-and-drop-xblock/18618