@Test public void testEnsureDynamicContentIsValid() throws Exception { final String cms = "<div> <% if (x) { %> <% def dyno1 = 10 % 3; \n" + "%> text here <% for (int i = 0; i < 10; i++) { %>\n" + "<span>in loop ${ i % 2 < 3 ? 'odd' : 'even'}</span>" + "<% } } else { %> no loop <% } %></div>"; final String edited = VoContentServiceUtils.ensureDynamicContentIsVisible(cms); assertEquals("<div> &lt;% if (x) { %&gt; &lt;% def dyno1 = 10 % 3; \n" + "%&gt; text here &lt;% for (int i = 0; i &lt; 10; i++) { %&gt;\n" + "<span>in loop ${ i % 2 &lt; 3 ? 'odd' : 'even'}</span>&lt;% } } else { %&gt; no loop &lt;% } %&gt;</div>", edited); assertEquals(cms, VoContentServiceUtils.ensureDynamicContentIsValid(edited)); }
static String ensureDynamicContentIsValid(final String edited) { String out = edited; out = parseCodeBlock(out, "&lt;%", "<%", "%&gt;", "%>", "&lt;", "<", "&gt;", ">"); out = parseCodeBlock(out, "${", "${", "}", "}", "&lt;", "<", "&gt;", ">"); return out; }
VoContentServiceUtils { static String ensureDynamicContentIsValid(final String edited) { String out = edited; out = parseCodeBlock(out, "&lt;%", "<%", "%&gt;", "%>", "&lt;", "<", "&gt;", ">"); out = parseCodeBlock(out, "${", "${", "}", "}", "&lt;", "<", "&gt;", ">"); return out; } }
VoContentServiceUtils { static String ensureDynamicContentIsValid(final String edited) { String out = edited; out = parseCodeBlock(out, "&lt;%", "<%", "%&gt;", "%>", "&lt;", "<", "&gt;", ">"); out = parseCodeBlock(out, "${", "${", "}", "}", "&lt;", "<", "&gt;", ">"); return out; }  }
VoContentServiceUtils { static String ensureDynamicContentIsValid(final String edited) { String out = edited; out = parseCodeBlock(out, "&lt;%", "<%", "%&gt;", "%>", "&lt;", "<", "&gt;", ">"); out = parseCodeBlock(out, "${", "${", "}", "}", "&lt;", "<", "&gt;", ">"); return out; }   }
VoContentServiceUtils { static String ensureDynamicContentIsValid(final String edited) { String out = edited; out = parseCodeBlock(out, "&lt;%", "<%", "%&gt;", "%>", "&lt;", "<", "&gt;", ">"); out = parseCodeBlock(out, "${", "${", "}", "}", "&lt;", "<", "&gt;", ">"); return out; }    }