};
}
+ public static class prettyEncodeHTMLGeneratorFunction implements Generator.GeneratorFunction {
+ public Object perform(List aParameters) throws GeneratorExc {
+ try {
+ if (aParameters.size()!=1)
+ throw new GeneratorExc("prettyEncodeHTMLGeneratorFunction: only 1 parameter expected");
+
+ return HTMLRoutines.prettyEncodeHTML(StringRoutines.interpretAsString(aParameters.get(0)));
+ }
+ catch (GeneratorExc e) {
+ throw e;
+ }
+ catch (Throwable t) {
+ throw new GeneratorFailure("prettyEncodeHTMLGeneratorFunction: " + t.getMessage(), t);
+ }
+ };
+ }
+
public static class encodeXMLGeneratorFunction implements Generator.GeneratorFunction {
public Object perform(List aParameters) throws GeneratorExc {
try {
return StringRoutines.replaceStringCharacters(aText, CHARACTERS_TO_ESCAPE, ESCAPE_CODES);
}
+ public static String prettyEncodeHTML(String aText) throws UtilExc {
+ return
+ StringRoutines.performRegularExpressionReplacement(encodeHTML(aText), "\\n", "<br>\n");
+ }
+
public static String encodeXML(String aText) {
-//#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ //#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"', '\'',
'\u0000', '\u0001', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', '\u0008', '\u0000', '\u000B',
'\u000C', '\u000E', '\u000F', '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016',
* @throws Exception\r
*/\r
public static String performRegularExpressionReplacement(String aSource,\r
- String aSearchExpression, String aReplacement) throws Exception {\r
+ String aSearchExpression, String aReplacement) throws UtilExc {\r
+ try {\r
+ RE regularExpression;\r
\r
- RE regularExpression;\r
+ regularExpression = new RE(aSearchExpression);\r
\r
- regularExpression = new RE(aSearchExpression);\r
+ return regularExpression.substituteAll(aSource, aReplacement);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new UtilFailure("StringRoutines.performRegularExpressionReplacement: " + t.toString(), t);\r
+ }\r
+ }\r
+\r
+ public static String performCaseInsensitiveRegularExpressionReplacement(String aSource,\r
+ String aSearchExpression, String aReplacement) throws UtilExc {\r
+ try {\r
+ RE regularExpression;\r
+\r
+ regularExpression = new RE(aSearchExpression, RE.REG_ICASE);\r
\r
- return regularExpression.substituteAll(aSource, aReplacement);\r
+ return regularExpression.substituteAll(aSource, aReplacement);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new UtilFailure("StringRoutines.performRegularExpressionReplacement: " + t.toString(), t);\r
+ }\r
}\r
\r
/**\r
* @throws REException\r
*/\r
public static boolean performRegularExpressionSearch(String aSource,\r
- String aSearchExpression) throws REException {\r
- RE regularExpression;\r
+ String aSearchExpression) throws UtilExc {\r
+ try {\r
+ RE regularExpression;\r
\r
- regularExpression = new RE(aSearchExpression);\r
+ regularExpression = new RE(aSearchExpression);\r
\r
- return regularExpression.isMatch(aSource);\r
+ return regularExpression.isMatch(aSource);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new UtilFailure("StringRoutines.performRegularExpressionSearch: " + t.toString(), t);\r
+ }\r
}\r
\r
/**\r
addSimpleAntiAbuseFilterType(new MirBasicAntiAbuseFilterTypes.IPFilter("ip"));
}
- public SessionHandler getOpenSessionHandler(String aSessionType) {
+ public SessionHandler getOpenSessionHandler(String aSessionType) throws MirLocalizerExc, MirLocalizerFailure {
/* if (aSessionType!=null && aSessionType.equals("email"))
return new MirBasicEmailArticleHandler();
*/
\r
utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace());\r
utilityMap.put("encodeHTML", new GeneratorHTMLFunctions.encodeHTMLGeneratorFunction());\r
+ utilityMap.put("prettyEncodeHTML", new GeneratorHTMLFunctions.prettyEncodeHTMLGeneratorFunction());\r
utilityMap.put("encodeXML", new GeneratorHTMLFunctions.encodeXMLGeneratorFunction());\r
utilityMap.put("encodeURI", new GeneratorHTMLFunctions.encodeURIGeneratorFunction());\r
utilityMap.put("subString", new GeneratorStringFunctions.subStringFunction());\r
<list aDataKeys as i>
<td>
- ${entry[i]}
+ ${utility.prettyEncodeHTML(entry[i])}
</td>
</list>
<if aShowDelete == "1" || aShowEdit == "1" >
<if entry.is_published!="0">Pub.<else>-</if> <if entry.is_html!="0">HTML<else>-</if>
</td>
<td>
- ${lang("articletypes." + entry.article_type.name)} <b>${entry.title}</b> (${entry.id})<br>
- ${lang("by")} <i>${utility.encodeHTML(entry.creator)}</i><br>
+ ${lang("articletypes." + entry.article_type.name)} <b>${utility.prettyEncodeHTML(entry.title)}</b> (${entry.id})<br>
+ ${lang("by")} <i>${utility.prettyEncodeHTML(entry.creator)}</i><br>
<if showactions=="1">
<if config["Mir.Localizer.Admin.ListOperationsFlavor"]=="0">
<list entry.operations as op>
</if>
</td>
<td width="25%" <if grey=="1">class="listrow3"<else>class="listrow4"</if> valign="top">
- <span class="small">${entry.comment} </span>
+ <span class="small">${utility.prettyEncodeHTML(entry.comment)} </span>
</td>
<td valign="top" class="listcommand">
<if showactions=="1">