hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r591177 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java src/test/org/apache/hadoop/hbase/shell/TestConsoleTable.java src/webapps/master/hql.jsp
Date Fri, 02 Nov 2007 00:43:08 GMT
Author: stack
Date: Thu Nov  1 17:43:07 2007
New Revision: 591177

URL: http://svn.apache.org/viewvc?rev=591177&view=rev
Log:
HADOOP-2137 hql.jsp : The character 0x19 is not valid

Removed:
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/TestConsoleTable.java
Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java
    lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/hql.jsp

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=591177&r1=591176&r2=591177&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Thu Nov  1 17:43:07 2007
@@ -19,6 +19,7 @@
    HADOOP-2124 Use of `hostname` does not work on Cygwin in some cases
    HADOOP-2083 TestTableIndex failed in #970 and #956
    HADOOP-2109 Fixed race condition in processing server lease timeout.
+   HADOOP-2137 hql.jsp : The character 0x19 is not valid
 
   IMPROVEMENTS
     HADOOP-2401 Add convenience put method that takes writable

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java?rev=591177&r1=591176&r2=591177&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/formatter/HtmlTableFormatter.java
Thu Nov  1 17:43:07 2007
@@ -2,11 +2,14 @@
 
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 
 import org.apache.hadoop.hbase.shell.TableFormatter;
 import org.znerd.xmlenc.LineBreak;
 import org.znerd.xmlenc.XMLOutputter;
+import org.znerd.xmlenc.XMLEncoder;
+import org.znerd.xmlenc.InvalidXMLException;
 
 /**
  * Formatter that outputs data inside an HTML table. If only a single cell
@@ -28,13 +31,56 @@
   private HtmlTableFormatter() {
     this(null);
   }
+
+  /*
+   * An encoder that replaces illegal XML characters with the '@' sign.
+   */
+  private static class HbaseXMLEncoder extends XMLEncoder {
+    @SuppressWarnings("deprecation")
+    public HbaseXMLEncoder()
+    throws IllegalArgumentException, UnsupportedEncodingException {
+      super("UTF-8");
+    }
+    
+    @Override
+    public void text(Writer w, char c, boolean escape)
+    throws InvalidXMLException, IOException {
+      super.text(w, legalize(c), escape);
+    }
+    
+    @Override
+    public void text(Writer w, char[] cs, int start, int length, boolean b)
+        throws NullPointerException, IndexOutOfBoundsException,
+        InvalidXMLException, IOException {
+      for (int i = start; i < start + length; i++) {
+        cs[i] = legalize(cs[i]);
+      }
+      super.text(w, cs, start, length, b);
+    }
+    
+    /**
+     * If character is in range A, C, or E, then replace with '@'
+     * <pre>
+     * A   0-8     Control characters   -- Not allowed in XML 1.0 --
+     * B   9-10    Normal characters    Never needed
+     * C   11-12   Control characters   -- Not allowed in XML 1.0 --
+     * D   13      Normal character     Never needed
+     * E   14-31   Control characters   -- Not allowed in XML 1.0 --
+     * </pre>
+     * @param c Character to look at.
+     * @return
+     */
+    private char legalize(final char c) {
+      return (c <= 8 || c == 11 || c == 12 || (c >= 14 && c <= 31))? '@':
c;
+    }
+  }
   
   public HtmlTableFormatter(final Writer o) {
     this.out = o;
     try {
       // Looking at the xmlenc source, there should be no issue w/ wrapping
       // the stream -- i.e. no hanging resources.
-      this.outputter = new XMLOutputter(this.out, "UTF-8");
+      this.outputter = new XMLOutputter(this.out, new HbaseXMLEncoder());
       String os = System.getProperty("os.name").toLowerCase();
       // Shell likes the DOS output.
       this.outputter.setLineBreak(os.contains("windows")?

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/hql.jsp
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/hql.jsp?rev=591177&r1=591176&r2=591177&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/hql.jsp (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/hql.jsp Thu Nov  1 17:43:07 2007
@@ -28,11 +28,11 @@
 <form action="/hql.jsp" method="get">
     <p>
     <label for="query">Query: </label>
-    <input type="text" name="q" id="q" size="40" value="<%= query %>" />
+    <input type="text" name="q" id="q" size="60" value="<%= query %>" />
     <input type="submit" value="submit" />
     </p>
  </form>
- <p>Enter 'help;' -- thats 'help' plus a semi-colon -- for a list of <em>HQL</em>
commands.
+ <p>Enter 'help;' -- thats 'help' plus a semi-colon -- for the list of <em>HQL</em>
commands.
  Data Definition, SHELL, INSERTS, DELETES, and UPDATE commands are disabled in this interface
  </p>
  



Mime
View raw message