congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
HtmlQuoting
Code IndexAdd Tabnine to your IDE (free)

How to use
HtmlQuoting
in
org.apache.hadoop.hbase.http

Best Java code snippets using org.apache.hadoop.hbase.http.HtmlQuoting (Showing top 20 results out of 315)

origin: apache/hbase

/**
 * Quote the given item to make it html-safe.
 * @param item the string to quote
 * @return the quoted string
 */
public static String quoteHtmlChars(String item) {
 if (item == null) {
  return null;
 }
 byte[] bytes = item.getBytes();
 if (needsQuoting(bytes, 0, bytes.length)) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
   quoteHtmlChars(buffer, bytes, 0, bytes.length);
  } catch (IOException ioe) {
   // Won't happen, since it is a bytearrayoutputstream
  }
  return buffer.toString();
 } else {
  return item;
 }
}
origin: apache/hbase

/**
 * Unquote the name and quote the value.
 */
@Override
public String getParameter(String name) {
 return HtmlQuoting.quoteHtmlChars(rawRequest.getParameter
                (HtmlQuoting.unquoteHtmlChars(name)));
}
origin: apache/hbase

@Override
public void write(int b) throws IOException {
 data[0] = (byte) b;
 quoteHtmlChars(out, data, 0, 1);
}
origin: apache/hbase

/**
 * Does the given string need to be quoted?
 * @param str the string to check
 * @return does the string contain any of the active html characters?
 */
public static boolean needsQuoting(String str) {
 if (str == null) {
  return false;
 }
 byte[] bytes = str.getBytes();
 return needsQuoting(bytes, 0 , bytes.length);
}
origin: apache/hbase

@Override
public void write(byte[] data, int off, int len) throws IOException {
 quoteHtmlChars(out, data, off, len);
}
origin: apache/hbase

@Test public void testNeedsQuoting() throws Exception {
 assertTrue(HtmlQuoting.needsQuoting("abcde>"));
 assertTrue(HtmlQuoting.needsQuoting("<abcde"));
 assertTrue(HtmlQuoting.needsQuoting("abc'de"));
 assertTrue(HtmlQuoting.needsQuoting("abcde\""));
 assertTrue(HtmlQuoting.needsQuoting("&"));
 assertFalse(HtmlQuoting.needsQuoting(""));
 assertFalse(HtmlQuoting.needsQuoting("ab\ncdef"));
 assertFalse(HtmlQuoting.needsQuoting(null));
}
origin: apache/hbase

@Override
public String[] getParameterValues(String name) {
 String unquoteName = HtmlQuoting.unquoteHtmlChars(name);
 String[] unquoteValue = rawRequest.getParameterValues(unquoteName);
 if (unquoteValue == null) {
  return null;
 }
 String[] result = new String[unquoteValue.length];
 for(int i=0; i < result.length; ++i) {
  result[i] = HtmlQuoting.quoteHtmlChars(unquoteValue[i]);
 }
 return result;
}
origin: apache/hbase

 @Override
 public String nextElement() {
  return HtmlQuoting.quoteHtmlChars(rawIterator.nextElement());
 }
};
origin: org.apache.hbase/hbase-http

/**
 * Quote the given item to make it html-safe.
 * @param item the string to quote
 * @return the quoted string
 */
public static String quoteHtmlChars(String item) {
 if (item == null) {
  return null;
 }
 byte[] bytes = item.getBytes();
 if (needsQuoting(bytes, 0, bytes.length)) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
   quoteHtmlChars(buffer, bytes, 0, bytes.length);
  } catch (IOException ioe) {
   // Won't happen, since it is a bytearrayoutputstream
  }
  return buffer.toString();
 } else {
  return item;
 }
}
origin: com.aliyun.hbase/alihbase-http

/**
 * Does the given string need to be quoted?
 * @param str the string to check
 * @return does the string contain any of the active html characters?
 */
public static boolean needsQuoting(String str) {
 if (str == null) {
  return false;
 }
 byte[] bytes = str.getBytes();
 return needsQuoting(bytes, 0 , bytes.length);
}
origin: apache/hbase

public static void main(String[] args) throws Exception {
 if (args.length == 0) {
   throw new IllegalArgumentException("Please provide some arguments");
 }
 for(String arg:args) {
  System.out.println("Original: " + arg);
  String quoted = quoteHtmlChars(arg);
  System.out.println("Quoted: "+ quoted);
  String unquoted = unquoteHtmlChars(quoted);
  System.out.println("Unquoted: " + unquoted);
  System.out.println();
 }
}
origin: apache/hbase

 /**
  * Quote the server name so that users specifying the HOST HTTP header
  * can't inject attacks.
  */
 @Override
 public String getServerName() {
  return HtmlQuoting.quoteHtmlChars(rawRequest.getServerName());
 }
}
origin: com.aliyun.hbase/alihbase-http

/**
 * Quote the given item to make it html-safe.
 * @param item the string to quote
 * @return the quoted string
 */
public static String quoteHtmlChars(String item) {
 if (item == null) {
  return null;
 }
 byte[] bytes = item.getBytes();
 if (needsQuoting(bytes, 0, bytes.length)) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
   quoteHtmlChars(buffer, bytes, 0, bytes.length);
  } catch (IOException ioe) {
   // Won't happen, since it is a bytearrayoutputstream
  }
  return buffer.toString();
 } else {
  return item;
 }
}
origin: org.apache.hbase/hbase-http

/**
 * Does the given string need to be quoted?
 * @param str the string to check
 * @return does the string contain any of the active html characters?
 */
public static boolean needsQuoting(String str) {
 if (str == null) {
  return false;
 }
 byte[] bytes = str.getBytes();
 return needsQuoting(bytes, 0 , bytes.length);
}
origin: apache/hbase

private void runRoundTrip(String str) throws Exception {
 assertEquals(str,
        HtmlQuoting.unquoteHtmlChars(HtmlQuoting.quoteHtmlChars(str)));
}
origin: apache/hbase

/**
 * Quote the url so that users specifying the HOST HTTP header
 * can't inject attacks.
 */
@Override
public StringBuffer getRequestURL(){
 String url = rawRequest.getRequestURL().toString();
 return new StringBuffer(HtmlQuoting.quoteHtmlChars(url));
}
origin: harbby/presto-connectors

/**
 * Quote the given item to make it html-safe.
 * @param item the string to quote
 * @return the quoted string
 */
public static String quoteHtmlChars(String item) {
 if (item == null) {
  return null;
 }
 byte[] bytes = item.getBytes();
 if (needsQuoting(bytes, 0, bytes.length)) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
   quoteHtmlChars(buffer, bytes, 0, bytes.length);
  } catch (IOException ioe) {
   // Won't happen, since it is a bytearrayoutputstream
  }
  return buffer.toString();
 } else {
  return item;
 }
}
origin: harbby/presto-connectors

/**
 * Does the given string need to be quoted?
 * @param str the string to check
 * @return does the string contain any of the active html characters?
 */
public static boolean needsQuoting(String str) {
 if (str == null) {
  return false;
 }
 byte[] bytes = str.getBytes();
 return needsQuoting(bytes, 0 , bytes.length);
}
origin: com.aliyun.hbase/alihbase-http

@Override
public String[] getParameterValues(String name) {
 String unquoteName = HtmlQuoting.unquoteHtmlChars(name);
 String[] unquoteValue = rawRequest.getParameterValues(unquoteName);
 if (unquoteValue == null) {
  return null;
 }
 String[] result = new String[unquoteValue.length];
 for(int i=0; i < result.length; ++i) {
  result[i] = HtmlQuoting.quoteHtmlChars(unquoteValue[i]);
 }
 return result;
}
origin: apache/hbase

@Override
public Map<String, String[]> getParameterMap() {
 Map<String, String[]> result = new HashMap<>();
 Map<String, String[]> raw = rawRequest.getParameterMap();
 for (Map.Entry<String,String[]> item: raw.entrySet()) {
  String[] rawValue = item.getValue();
  String[] cookedValue = new String[rawValue.length];
  for(int i=0; i< rawValue.length; ++i) {
   cookedValue[i] = HtmlQuoting.quoteHtmlChars(rawValue[i]);
  }
  result.put(HtmlQuoting.quoteHtmlChars(item.getKey()), cookedValue);
 }
 return result;
}
org.apache.hadoop.hbase.httpHtmlQuoting

Javadoc

This class is responsible for quoting HTML characters.

Most used methods

  • needsQuoting
    Does the given string need to be quoted?
  • quoteHtmlChars
    Quote the given item to make it html-safe.
  • unquoteHtmlChars
    Remove HTML quoting from a string.

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getResourceAsStream (ClassLoader)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • ImageIO (javax.imageio)
  • JTextField (javax.swing)
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now