HADOOP-2137 hql.jsp : The character 0x19 is not valid

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@591177 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2007-11-02 00:43:07 +00:00
parent 2bd1e2cac2
commit d8f4792f8e
4 changed files with 50 additions and 40 deletions

View File

@ -19,6 +19,7 @@ Trunk (unreleased changes)
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

View File

@ -2,11 +2,14 @@ package org.apache.hadoop.hbase.shell.formatter;
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 @@ public class HtmlTableFormatter implements TableFormatter {
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")?

View File

@ -1,37 +0,0 @@
/**
* Copyright 2007 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.shell;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
* Test the console table class
*/
public class TestConsoleTable extends TestCase {
public void testPrintTable() {
}
public static void main(String[] args) {
TestRunner.run(new TestSuite(TestConsoleTable.class));
}
}

View File

@ -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>