You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] A code template with an XML-illegal character (U+FFFE) makes the JSON code template list fail #566
If a code template contains a character that is not allowed in XML 1.0 (for example U+FFFE or U+FFFF), the JSON variant of the code template REST API fails for the whole list. The XML variant still works, so the Swing Administrator loads the templates normally, but every client that asks for JSON (such as the web administrator) gets an error and sees no code templates at all.
Steps to reproduce
Create a code template whose code contains a raw U+FFFE character, for example in a regex: s.replace(/[<U+FFFE><U+FFFF>]/g, "") with the actual characters instead of � / � escapes.
Save it (the Swing Administrator accepts it).
Request the code templates as JSON, e.g. GET /api/codeTemplates with Accept: application/json.
Expected
The list is returned. The character is either escaped/stripped on output, or rejected with a clear message when the template is saved.
Actual
The request fails with a server error. The server log shows, for every request:
ERROR com.mirth.connect.model.converters.ObjectJSONSerializer: javax.xml.transform.TransformerException: com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0xfffe)
ObjectJSONSerializer converts the object to XML first and then parses that XML with Woodstox to build the JSON. The XML contains , which is illegal in XML 1.0, so the parse fails. One bad template blocks the whole list.
Notes
Seen on OIE 4.6.0. The characters came from a JavaScript file pasted into a code template, so this can happen by accident.
Workaround: open the template in the Swing Administrator, remove the characters (use � escapes), and save.
The same path is probably used for channels, global scripts and other objects with free-text script fields, so they are likely affected too.
Possible fixes: strip or escape XML-illegal characters when serialising to JSON, and/or reject them on save with a message that names the template.
Activity