Fix export of newly-uploaded images #2055
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think this PR arranges so that images newly uploaded by verified professors to casebooks will appear in DOCX exports of those casebooks.
It turns off all the URL munging that TinyMCE, the rich text editor, does on save. It is unclear to me why it munges URLs by default. The docs say:
But I do not know what that means.
The route that handles uploads returns the absolute URL of the upload: so, without any munging, we should get what we want.
Testing locally manually, it works. Adding a functional test to actually try it out as part of the test suite is way hard, so I'm not going to, at this point.
If for some reason this does not work in prod the same way it does locally, we can try again, this time configuring TinyMCE to use custom logic to force all image URLs to be absolute links to H2O, while leaving non-image links untouched. Fingers crossed it doesn't come to that 🤞.
I added a basic test so that I could feel less worried that we are exposed to exfiltration, or similar, if relative paths are manually added to the TextBlock source by accident or by a mischievous user.
As a followup, I plan to spend a little time finding all the image tags in H2O casebooks text, and a) clean up any that I can, so that their export works retroactively, and b) possibly, deal with any other bad ones that turn up.
I am resisting the urge to do any further refactoring... which is extremely tempting.