Rework escaping of special characters in message properties for account console (#9995)

Closes #9503
This commit is contained in:
Alexander Schwartz 2022-02-07 20:47:03 +01:00 committed by GitHub
parent 5494848f3f
commit 100dbb8781
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -168,10 +168,11 @@ public class AccountConsole {
}
private String convertPropValue(String propertyValue) {
propertyValue = propertyValue.replace("''", "%27");
propertyValue = propertyValue.replace("'", "%27");
propertyValue = propertyValue.replace("\"", "%22");
// this mimics the behavior of java.text.MessageFormat used for the freemarker templates:
// To print a single quote one needs to write two single quotes.
// Single quotes will be stripped.
// Usually single quotes would escape parameters, but this not implemented here.
propertyValue = propertyValue.replaceAll("'('?)", "$1");
propertyValue = putJavaParamsInNgTranslateFormat(propertyValue);
return propertyValue;

View file

@ -62,7 +62,9 @@
<#if msg??>
var locale = '${locale}';
var l18nMsg = JSON.parse('${msgJSON?no_esc}');
<#outputformat "JavaScript">
var l18nMsg = JSON.parse('${msgJSON?js_string}');
</#outputformat>
<#else>
var locale = 'en';
var l18Msg = {};

View file

@ -58,7 +58,7 @@ export class Msg extends React.Component<MsgProps> {
})
}
return unescape(message);
return message;
}
// if the message key has Freemarker syntax, remove it