Skip to content
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

EML Drafts unescape XML entities #1944

Closed
laurenwalker opened this issue Jan 7, 2022 · 3 comments
Closed

EML Drafts unescape XML entities #1944

laurenwalker opened this issue Jan 7, 2022 · 3 comments
Assignees
Labels

Comments

@laurenwalker
Copy link
Member

laurenwalker commented Jan 7, 2022

Steps to reproduce:

  1. Copy the following text into a field in the editor, e.g. the abstract: • Amory, C., Kittel, C., Le Toumelin, L., Agosta, C., Delhasse, A., Favier, V., & Fettweis, X. (2021). Performance of MAR (v3.11) in simulating the drifting-snow

  2. Submit the dataset with that text in the EML. Note that the ampersand character was escaped correctly by the editor.

  3. Go to the DraftsView and Download or Copy the draft. Open the draft EML in a text editor and note that the ampersand is not escaped.

When I inspect in the developer tools the EML string that is locally saved to localforage, I see that the ampersand is escaped. So something is happening during the Download and Copy process that is unescaping XML entities.

This is causing issues when the ADC data team is using the draft XML file to reupload the EML to Metacat.

@amoeba
Copy link
Contributor

amoeba commented Jan 7, 2022

Thanks for filing this @laurenwalker. I'll have a look.

amoeba added a commit that referenced this issue Jan 7, 2022
Fixes #1944

Both the Copy to Clipboard and Download buttons are driven off of the value in a hidden textarea that's inserted into the DOM. ie every draft has a textarea element whose value is the corresponding draft XML.

#1944 describes a situation where drafts with reserved characters -- which we normally escape before serialization -- would download or copy in a de-escaped form. This would result in invalid XML for downloaded or copied drafts.

Underscore has an escaping interpolator (<%-) that ensures the interpolated values is escape so this change switches to that interpolator. I've tested with a simple example document and made sure the Download, Copy to Clipboard, and Download All buttons are producing valid XML.
@amoeba
Copy link
Contributor

amoeba commented Jan 7, 2022

I think I've got it fixed in 9479cae. See the commit message for more info.

To verify my change, re-trace the initial steps above and see the Download, Copy to Clipboard, and Download All buttons produce valid XML. I've moved this into Needs Review/Test in case you want to have a look @laurenwalker.

@laurenwalker
Copy link
Member Author

Thanks Bryce, I tested this out and it works great now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants