]> WPIA git - gigi.git/commitdiff
FIX: a bug in evaluating sprintf-template-statments
authorFelix Dörre <felix@dogcraft.de>
Wed, 5 Nov 2014 09:16:20 +0000 (10:16 +0100)
committerJanis Streib <janis@dogcraft.de>
Wed, 31 Dec 2014 01:36:02 +0000 (02:36 +0100)
src/org/cacert/gigi/output/template/SprintfCommand.java
tests/org/cacert/gigi/template/TestTemplate.java

index 2d174d3193f6f8d684ab5b425b75bbd164f63cb2..17ef23a8240d7181c428b2d432ac371ca3c0f6d2 100644 (file)
@@ -21,7 +21,7 @@ public final class SprintfCommand implements Outputable {
 
     @Override
     public void output(PrintWriter out, Language l, Map<String, Object> vars) {
-        String[] parts = l.getTranslation(text).split("%s");
+        String[] parts = l.getTranslation(text).split("%s", -1);
         String[] myvars = store.toArray(new String[store.size()]);
         out.print(HTMLEncoder.encodeHTML(parts[0]));
         for (int j = 1; j < parts.length; j++) {
index 19b8768df0339c6298147923a0986f79829e41e6..50b1d693a30183626fd57ad16ffb45ddafd2ac28 100644 (file)
@@ -56,6 +56,7 @@ public class TestTemplate {
         assertEquals("This val\"> val3<\" the val4> textl", testExecute(Language.getInstance(Locale.ENGLISH), vars, "<?=s,$!var,$!var2,$!var3,This %s %s the %s text?>l"));
 
         assertEquals("This blargh&lt;&gt;!, <>! textl", testExecute(Language.getInstance(Locale.ENGLISH), vars, "<?=s,\"blargh<>!\",!\"<>!\",This %s, %s text?>l"));
+        assertEquals("This blargh&lt;&gt;!, <>!l", testExecute(Language.getInstance(Locale.ENGLISH), vars, "<?=s,\"blargh<>!\",!\"<>!\",This %s, %s?>l"));
     }
 
     @Test