*** empty log message ***
authorzapata <zapata>
Tue, 16 Sep 2003 01:26:28 +0000 (01:26 +0000)
committerzapata <zapata>
Tue, 16 Sep 2003 01:26:28 +0000 (01:26 +0000)
source/mir/util/GeneratorHTMLFunctions.java
source/mir/util/HTMLRoutines.java
source/mir/util/StringRoutines.java
source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java
source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java
templates/admin/FUNCTIONS.template
templates/admin/contentlist.template

index 661ff56..9825ca2 100755 (executable)
@@ -78,6 +78,23 @@ public class GeneratorHTMLFunctions {
     };
   }
 
+  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 {
index 07f40a0..4ed503b 100755 (executable)
@@ -63,8 +63,13 @@ public class HTMLRoutines {
     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',
index a3ac35c..840e6e2 100755 (executable)
@@ -125,13 +125,31 @@ public class StringRoutines {
    * @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
@@ -142,12 +160,17 @@ public class StringRoutines {
    * @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
index bfa42df..f6fe4a2 100755 (executable)
@@ -83,7 +83,7 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer {
     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();
 */
index f3a8eaa..d4c3f30 100755 (executable)
@@ -84,6 +84,7 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
 \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
index 2b1eeed..3d72602 100755 (executable)
@@ -50,7 +50,7 @@
         
         <list aDataKeys as i>   
             <td>
-              ${entry[i]}
+              ${utility.prettyEncodeHTML(entry[i])}
             </td>
         </list>
         <if aShowDelete == "1" || aShowEdit == "1" >
index e580010..c6c3f00 100755 (executable)
@@ -68,8 +68,8 @@
           <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}&nbsp;</span>
+        <span class="small">${utility.prettyEncodeHTML(entry.comment)}&nbsp;</span>
       </td>
       <td valign="top" class="listcommand">
         <if showactions=="1">