Skip to content

Commit

Permalink
Fix string escaping issues (#8058)
Browse files Browse the repository at this point in the history
- Escape strings in Expression.toString in OMC.
- Handle escaped characters inside strings in StringHandler::getStrings
  in OMEdit.
  • Loading branch information
perost committed Oct 28, 2021
1 parent a61de2e commit fedf620
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -1613,7 +1613,7 @@ public
str := match exp
case INTEGER() then intString(exp.value);
case REAL() then realString(exp.value);
case STRING() then "\"" + exp.value + "\"";
case STRING() then "\"" + System.escapedString(exp.value, false) + "\"";
case BOOLEAN() then boolString(exp.value);

case ENUM_LITERAL(ty = t as Type.ENUMERATION())
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditLIB/Util/StringHandler.cpp
Expand Up @@ -911,6 +911,8 @@ QStringList StringHandler::getStrings(QString value)
} else if (str_char) {
if (c == str_char) {
str_char = 0;
} else if (c == '\\') {
escaped = true;
}
continue;
}
Expand Down

0 comments on commit fedf620

Please sign in to comment.