X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2Ftemplate%2FSprintfCommand.java;h=64ede7823776692b11f7e2ba6100e1e07d9d6a3d;hp=cbd79e57a14ebfface943921c8b1b0765d568406;hb=dd2df5279f12cb801851244785a9ebc2566b6ef5;hpb=06fff0058cc341b53a5fd57a0afc8b2c1d906d28 diff --git a/src/org/cacert/gigi/output/template/SprintfCommand.java b/src/org/cacert/gigi/output/template/SprintfCommand.java index cbd79e57..64ede782 100644 --- a/src/org/cacert/gigi/output/template/SprintfCommand.java +++ b/src/org/cacert/gigi/output/template/SprintfCommand.java @@ -23,7 +23,7 @@ public final class SprintfCommand implements Translatable { private final String[] store; /** - * Creates a new SprintfCommand based on its pre-parsed contents + * Creates a new SprintfCommand based on its pre-parsed contents. * * @param text * a string with {0},{1},.. as placeholders. @@ -44,7 +44,7 @@ public final class SprintfCommand implements Translatable { * Creates a new SprintfCommand that is parsed as from template source. * * @param content - * the part from the template that is to be parsed + * the part from the template that is to be parsed. */ protected SprintfCommand(String content) { StringBuffer raw = new StringBuffer(); @@ -78,7 +78,7 @@ public final class SprintfCommand implements Translatable { Matcher m = replacant.matcher(parts); int pos = 0; while (m.find()) { - out.print(HTMLEncoder.encodeHTML(parts.substring(pos, m.start()))); + out.print(escape(vars, parts.substring(pos, m.start()))); String var = store[Integer.parseInt(m.group(1))]; if (var.startsWith("$!")) { Template.outputVar(out, l, vars, var.substring(3, var.length() - 1), true); @@ -92,7 +92,14 @@ public final class SprintfCommand implements Translatable { pos = m.end(); } - out.print(HTMLEncoder.encodeHTML(parts.substring(pos))); + out.print(escape(vars, parts.substring(pos))); + } + + private String escape(Map vars, String target) { + if (vars.containsKey(OUT_KEY_PLAIN)) { + return target; + } + return HTMLEncoder.encodeHTML(target); } @Override @@ -109,9 +116,9 @@ public final class SprintfCommand implements Translatable { * as placeholders. * @param vars * the variables to put into the placeholders. - * @return the constructed {@link Outputable} + * @return the constructed {@link Outputable}. */ - public static Outputable createSimple(String msg, String... vars) { + public static Outputable createSimple(String msg, Object... vars) { HashMap scope = new HashMap<>(); String[] store = new String[vars.length]; for (int i = 0; i < vars.length; i++) {