]> WPIA git - gigi.git/commitdiff
UPD: change sprintf-template-syntax for literals
authorFelix Dörre <felix@dogcraft.de>
Mon, 29 Sep 2014 07:19:41 +0000 (09:19 +0200)
committerJanis Streib <janis@dogcraft.de>
Wed, 31 Dec 2014 01:35:42 +0000 (02:35 +0100)
doc/TemplateSyntax.txt
src/org/cacert/gigi/output/template/SprintfCommand.java
src/org/cacert/gigi/output/template/Template.java
src/org/cacert/gigi/pages/wot/RequestTTPPage.templ

index 47b36e905c3d70eeb55b6afd4a732fb3c0e34924..2ed1e546074493495a2012a4fced4118ea3d2cde 100644 (file)
@@ -11,7 +11,8 @@ A template is constructed from a charstream. Everything that is not in "<?" to "
 
 - <?=$!variablename?> will output the variable "variablename" but not HTML-escaped
 - <?=s,$!variablename,My %s text?> will insert the variable "variablename" into the translated text but not HTML-escaped
-- <?=s,"some data",My %s text?> will insert "some data" into the translated text literally (not HTML-escaped)
+- <?=s,"some data",My %s text?> will insert "some data" into the translated text
+- <?=s,!"some data",My %s text?> will insert "some data" into the translated text literally (not HTML-escaped)
   
 - <? if($variable) { ?>
   Output/execute the text until "<? } ?>" only if $variable not null or Boolean.FALSE.
index 0275219b983366b1781e579260ab48f0d602233c..2d174d3193f6f8d684ab5b425b75bbd164f63cb2 100644 (file)
@@ -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);
             }
index 69f17bda11db9cf6774e74e1f146aa6c0af2d88e..dca6568b7432847f4db4cca56f9840e9bc9cab41 100644 (file)
@@ -121,10 +121,10 @@ public class Template implements Outputable {
         } else if (s2.startsWith("=s,")) {
             String command = s2.substring(3);
             final LinkedList<String> store = new LinkedList<String>();
-            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(",");
index 163e781761ade1eba35ce5a66b00c894a4b7446a..9ff6114be22e923a895e663cb6b54ed5590e8de1 100644 (file)
@@ -12,7 +12,7 @@
 
 <p><?=_In the meanwhile you would need to close this gap with face to face assurances with CAcert Assurers. Think not only travelling to populated countries, but also remember that assurers may occasionally visit your country or area.?></p>
 
-<p><?=s,"<a href='//wiki.cacert.org/TTP/TTPuser'>https://wiki.cacert.org/TTP/TTPuser</a>","<a href='//wiki.cacert.org/TTP/TTPAL'>https://wiki.cacert.org/TTP/TTPAL</a>",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.?> </p>
+<p><?=s,!"<a href='//wiki.cacert.org/TTP/TTPuser'>https://wiki.cacert.org/TTP/TTPuser</a>",!"<a href='//wiki.cacert.org/TTP/TTPAL'>https://wiki.cacert.org/TTP/TTPAL</a>",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.?> </p>
 
 <? if($ttp) { ?>
 <p><?=_If you want to ask for TTP assurances fill out the missing data and send the request to support@cacert.org to start the process. CAcert will then inform you about the next steps.?></p>