Small corrections. BLD200206270100
authorralphk@netbeans.org
Wed, 26 Jun 2002 19:59:46 +0000
changeset 903ac6175655676
parent 902 1b78e8db1fb5
child 904 f1b1efc88614
Small corrections.
The temp file extension fixed.
texts escaped not to include <,>,&
javacvs/changelog/src/org/netbeans/modules/changelog/LogPrinter_HTML.java
     1.1 --- a/javacvs/changelog/src/org/netbeans/modules/changelog/LogPrinter_HTML.java	Wed Jun 26 16:25:58 2002 +0000
     1.2 +++ b/javacvs/changelog/src/org/netbeans/modules/changelog/LogPrinter_HTML.java	Wed Jun 26 19:59:46 2002 +0000
     1.3 @@ -35,7 +35,7 @@
     1.4          writer = null;
     1.5          try {
     1.6              if (this.file == null) {
     1.7 -                this.file = File.createTempFile("chlog", "hmtl");
     1.8 +                this.file = File.createTempFile("chlog", ".html");
     1.9              }
    1.10              if (!file.exists()) {
    1.11                  try {
    1.12 @@ -68,11 +68,11 @@
    1.13          
    1.14          writer.println("<H1> Query: </H1>");
    1.15          if (processor.getDateRange() != null) {
    1.16 -            writer.println("   Date Range: " + processor.getDateRange());
    1.17 +            writer.println("   Date Range: " + escapeString(processor.getDateRange()));
    1.18              writer.println("<P>");
    1.19          }
    1.20          if (processor.getRevisionRange() != null) {
    1.21 -            writer.println("   Revision Filter:" + processor.getRevisionRange());
    1.22 +            writer.println("   Revision Filter:" + escapeString(processor.getRevisionRange()));
    1.23              writer.println("<P>");
    1.24          }
    1.25          if (processor.getMessageFilter() != null) {
    1.26 @@ -86,7 +86,7 @@
    1.27              } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_REGEXP) {
    1.28                  messageType = "Regular expression";
    1.29              }
    1.30 -            writer.println("   Message Filter (" + messageType + "):" + processor.getMessageFilter());
    1.31 +            writer.println("   Message Filter (" + escapeString(messageType) + "):" + escapeString(processor.getMessageFilter()));
    1.32              writer.println("<P>");
    1.33          }
    1.34          if (processor.getFileFilter() != null) {
    1.35 @@ -96,7 +96,7 @@
    1.36              } else if (processor.getFileFilterType() == ChangeLogProcessor.FILE_FILTER_REGEXP) {
    1.37                  fileType = "Regular expression";
    1.38              }
    1.39 -            writer.println("   Contained Files Filter (" + fileType + "):" + processor.getFileFilter());
    1.40 +            writer.println("   Contained Files Filter (" + escapeString(fileType) + "):" + escapeString(processor.getFileFilter()));
    1.41              writer.println("<P>");
    1.42          }
    1.43          if (processor.getSortMode() == ChangeLogProcessor.SORT_BY_DATE) {
    1.44 @@ -121,9 +121,9 @@
    1.45          } 
    1.46          writer.println("<UL>");
    1.47            writer.println("--------------------------------------------------");
    1.48 -          writer.println("<LI>User: <B>" + group.getUser() + "</B>");
    1.49 -          writer.println("<LI>Date: <B>" + group.getStartingDate() + "</B>");
    1.50 -          writer.println("<LI>Message: <I>" + group.getMessage() + "</I>");
    1.51 +          writer.println("<LI>User: <B>" + escapeString(group.getUser()) + "</B>");
    1.52 +          writer.println("<LI>Date: <B>" + escapeString(group.getStartingDate().toString()) + "</B>");
    1.53 +          writer.println("<LI>Message: <I>" + escapeString(group.getMessage()) + "</I>");
    1.54            writer.println("<UL>");
    1.55      }
    1.56      
    1.57 @@ -155,10 +155,10 @@
    1.58          writer.print("<B>Developers: </B>");
    1.59          String[] users = processor.getUserList();
    1.60          for (int i = 0; i < users.length; i++) {
    1.61 -            if (i < users.length) {
    1.62 -                writer.print(users[i] + ", ");
    1.63 +            if (i != users.length - 1) {
    1.64 +                writer.print(escapeString(users[i]) + ", ");
    1.65              } else {
    1.66 -                writer.print(users[i]);
    1.67 +                writer.print(escapeString(users[i]));
    1.68              }
    1.69          }
    1.70          writer.println("<P> <BR>");
    1.71 @@ -166,7 +166,7 @@
    1.72          writer.println("<B>Most frequently changed files:</B>");
    1.73          writer.println("<UL>");
    1.74          for (int j = 0; j < mostChanged.length; j++) {
    1.75 -            writer.println("<LI>" + mostChanged[j]);
    1.76 +            writer.println("<LI>" + escapeString(mostChanged[j]));
    1.77          }
    1.78          writer.println("</UL>");
    1.79          writer.println("<P> <BR>");
    1.80 @@ -174,7 +174,7 @@
    1.81          String[] mostActive= processor.getMostActiveUsers();
    1.82          writer.println("<UL>");
    1.83          for (int k = 0; k < mostActive.length; k++) {
    1.84 -            writer.println("<LI>" + mostActive[k]);
    1.85 +            writer.println("<LI>" + escapeString(mostActive[k]));
    1.86          }
    1.87          writer.println("</UL>");
    1.88          writer.println("<P> <BR>");
    1.89 @@ -198,5 +198,27 @@
    1.90          
    1.91          
    1.92      }
    1.93 +
    1.94 +    private static final char[] charArray = new char[] {'>', '<', '&'};
    1.95 +    private static final String[] stringArray = 
    1.96 +        new String[] { "&gt;", "&lt;", "&amp;"};
    1.97 +    
    1.98 +    public static String escapeString(String original) {
    1.99 +        StringBuffer buffer = new StringBuffer(original);
   1.100 +        int index = 0;
   1.101 +        while (index < buffer.length()) {
   1.102 +            char character = buffer.charAt(index);
   1.103 +            for (int i = 0; i < charArray.length; i++) {
   1.104 +                if (character == charArray[i]) {
   1.105 +                    buffer.deleteCharAt(index);
   1.106 +                    buffer.insert(index, stringArray[i]);
   1.107 +                    index = index + stringArray[i].length();
   1.108 +                    continue;
   1.109 +                }
   1.110 +            }
   1.111 +            index = index + 1;
   1.112 +        }
   1.113 +        return buffer.toString();
   1.114 +    }
   1.115      
   1.116  }