Skip to content

Commit

Permalink
Escape new line characters in xml strings. (#9512)
Browse files Browse the repository at this point in the history
  - Our xml parser (expat) does not seem to parse newlines in xml attributes.
    So change
      - all new lines `(\n)` to their xml value `
`
      - all carrage returns `(\r)` to their xml value `
`

    before writing them to the xml files.

    It might be some settting we have to set for expat. Maybe someone who
    knows expat can suggest an alternative.

  - Fixes #9429.
  • Loading branch information
mahge committed Oct 14, 2022
1 parent 093ed4c commit 057b86d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OMCompiler/Compiler/Util/Util.mo
Expand Up @@ -919,6 +919,8 @@ algorithm
xmlString := System.stringReplace(xmlString, "\"", """);
xmlString := System.stringReplace(xmlString, "<", "&lt;");
xmlString := System.stringReplace(xmlString, ">", "&gt;");
xmlString := System.stringReplace(xmlString, "\n", "&#10;");
xmlString := System.stringReplace(xmlString, "\r", "&#13;");
// TODO! FIXME!, we have issues with accented chars in comments
// that end up in the Model_init.xml file and makes it not well
// formed but the line below does not work if the xmlString is
Expand Down

0 comments on commit 057b86d

Please sign in to comment.