Escape description for use in datacite xml (file and datacite api call) #7798
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.
What this PR does / why we need it: Adds escaping appropriate for include text in an xml doc to the description metadata in the DataCite metadata export/the same xml metadata as sent to the DataCite server via API during publication.
Which issue(s) this PR closes:
Closes #3328
Special notes for your reviewer: If I recall, some fields like title are escaped when created so additional escaping at this stage isn't needed. I haven't checked the status of all the other fields that get included (creator, publisher, contributor) where, if they aren't being escaped now, special chars could still cause an issue. That said, the description field seems like a key one to cover where most of the practical examples of special chars being used have shown up, so I think this is a useful step, although it won't stop problems from special chars in other fields if they indeed aren't already handled.
Suggestions on how to test this: The best test would be to have a test server configured with a test DataCite account and verify that a description with & < > * etc. fails before the PR and works afterwards. However, as noted in the issue, demo.dataverse.org seems to allow publication without this even though it appears to use the DataCite test server now.
A simpler test would be to just verify by inspection that the datacite metadata export file is valid xml, either by using a browser than can display xml (and not seeing an error like the one shown in the issue) or doing a view page source and seeing that characters such as & are escaped in the source (i.e. as & in this case).
Does this PR introduce a user interface change? If mockups are available, please link/include them here: no
Is there a release notes update needed for this change?: could note the fix
Additional documentation: