This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 88634b3411 Automate handing of POEditor's over zealous escaping 88634b3411 is described below commit 88634b3411c83adfd846b569a136e95902a42e93 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jul 13 15:07:30 2022 +0100 Automate handing of POEditor's over zealous escaping --- .../apache/tomcat/buildutil/translate/Import.java | 5 ++++- .../apache/tomcat/buildutil/translate/Utils.java | 25 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/buildutil/translate/Import.java b/java/org/apache/tomcat/buildutil/translate/Import.java index 1dcdd12375..0c02e69a9a 100644 --- a/java/org/apache/tomcat/buildutil/translate/Import.java +++ b/java/org/apache/tomcat/buildutil/translate/Import.java @@ -78,7 +78,10 @@ public class Import { w.write(System.lineSeparator()); } - w.write(cKey.key + "=" + Utils.formatValueImport(value)); + value = Utils.formatValueImport(value); + value = Utils.fixUnnecessaryEscaping(cKey.key, value); + + w.write(cKey.key + "=" + value); w.write(System.lineSeparator()); } if (w != null) { diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java b/java/org/apache/tomcat/buildutil/translate/Utils.java index 80a7756a23..03d8b91cdb 100644 --- a/java/org/apache/tomcat/buildutil/translate/Utils.java +++ b/java/org/apache/tomcat/buildutil/translate/Utils.java @@ -26,17 +26,28 @@ import java.io.Reader; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.HashSet; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.regex.Pattern; public class Utils { private static final Pattern ESCAPE_LEADING_SPACE = Pattern.compile("^(\\s)", Pattern.MULTILINE); + private static final Set<String> KEYS_WITH_UNNECESSARY_ESCAPING = new HashSet<>(); + // Package private so it is visible to tests static final String PADDING = "POEDITOR_EXPORT_PADDING_DO_NOT_DELETE"; + static { + KEYS_WITH_UNNECESSARY_ESCAPING.add("arrays.malformed.arrays"); + KEYS_WITH_UNNECESSARY_ESCAPING.add("jsp.error.attribute.deferredmix"); + KEYS_WITH_UNNECESSARY_ESCAPING.add("jsp.error.el.template.deferred"); + } + + private Utils() { // Utility class. Hide default constructor. } @@ -86,6 +97,20 @@ public class Utils { } + /* + * Values containing "[{n}]" and "'" need to have the "'" escaped as "''". + * POEditor attempts to do this automatically but does it for any value + * containing "{" or "}" leading to some unnecessary escaping. This method + * undoes the unnecessary escaping. + */ + static String fixUnnecessaryEscaping(String key, String value) { + if (KEYS_WITH_UNNECESSARY_ESCAPING.contains(key)) { + return value.replace("''", "'"); + } + return value; + } + + /* * Common formatting to convert a String for storage as a value in a * property file. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org