From 7e1a029d9df4c731a2087e58f774e6d8737aace3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Mon, 29 Sep 2014 09:19:41 +0200 Subject: [PATCH] UPD: change sprintf-template-syntax for literals --- doc/TemplateSyntax.txt | 3 ++- src/org/cacert/gigi/output/template/SprintfCommand.java | 4 +++- src/org/cacert/gigi/output/template/Template.java | 6 +++--- src/org/cacert/gigi/pages/wot/RequestTTPPage.templ | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/TemplateSyntax.txt b/doc/TemplateSyntax.txt index 47b36e90..2ed1e546 100644 --- a/doc/TemplateSyntax.txt +++ b/doc/TemplateSyntax.txt @@ -11,7 +11,8 @@ A template is constructed from a charstream. Everything that is not in " will output the variable "variablename" but not HTML-escaped - will insert the variable "variablename" into the translated text but not HTML-escaped -- will insert "some data" into the translated text literally (not HTML-escaped) +- will insert "some data" into the translated text +- will insert "some data" into the translated text literally (not HTML-escaped) - Output/execute the text until "" only if $variable not null or Boolean.FALSE. diff --git a/src/org/cacert/gigi/output/template/SprintfCommand.java b/src/org/cacert/gigi/output/template/SprintfCommand.java index 0275219b..2d174d31 100644 --- a/src/org/cacert/gigi/output/template/SprintfCommand.java +++ b/src/org/cacert/gigi/output/template/SprintfCommand.java @@ -28,8 +28,10 @@ public final class SprintfCommand implements Outputable { String var = myvars[j - 1]; if (var.startsWith("$!")) { Template.outputVar(out, l, vars, myvars[j - 1].substring(2), true); + } else if (var.startsWith("!\"")) { + out.print(var.substring(2)); } else if (var.startsWith("\"")) { - out.print(var.substring(1)); + out.print(HTMLEncoder.encodeHTML(var.substring(1))); } else { Template.outputVar(out, l, vars, myvars[j - 1].substring(1), false); } diff --git a/src/org/cacert/gigi/output/template/Template.java b/src/org/cacert/gigi/output/template/Template.java index 69f17bda..dca6568b 100644 --- a/src/org/cacert/gigi/output/template/Template.java +++ b/src/org/cacert/gigi/output/template/Template.java @@ -121,10 +121,10 @@ public class Template implements Outputable { } else if (s2.startsWith("=s,")) { String command = s2.substring(3); final LinkedList store = new LinkedList(); - while (command.startsWith("$") || command.startsWith("\"")) { + while (command.startsWith("$") || command.startsWith("\"") || command.startsWith("!\"")) { int idx; - if (command.startsWith("\"")) { - idx = command.indexOf("\"", 1) + 1; + if (command.startsWith("\"") || command.startsWith("!\"")) { + idx = command.indexOf("\"", command.charAt(0) == '!' ? 2 : 1) + 1; store.add(command.substring(0, idx - 1)); } else { idx = command.indexOf(","); diff --git a/src/org/cacert/gigi/pages/wot/RequestTTPPage.templ b/src/org/cacert/gigi/pages/wot/RequestTTPPage.templ index 163e7817..9ff6114b 100644 --- a/src/org/cacert/gigi/pages/wot/RequestTTPPage.templ +++ b/src/org/cacert/gigi/pages/wot/RequestTTPPage.templ @@ -12,7 +12,7 @@

-

https://wiki.cacert.org/TTP/TTPuser","https://wiki.cacert.org/TTP/TTPAL",If you are interested in the TTP programme, read the pages %s for the basic way how the TTP programme works for you, and %s whether the TTP programme affects the country where you are located.?>

+

https://wiki.cacert.org/TTP/TTPuser",!"https://wiki.cacert.org/TTP/TTPAL",If you are interested in the TTP programme, read the pages %s for the basic way how the TTP programme works for you, and %s whether the TTP programme affects the country where you are located.?>

-- 2.39.2