Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
EscapeUtil.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.coreutils;
20 
21 import java.io.UnsupportedEncodingException;
22 import java.net.URLDecoder;
23 import java.net.URLEncoder;
24 import java.util.logging.Level;
25 import org.apache.commons.lang3.StringEscapeUtils;
26 
30 public class EscapeUtil {
31 
32  private static final Logger logger = Logger.getLogger(EscapeUtil.class.getName());
33 
40  public static String decodeURL(String url) {
41  try {
42  return URLDecoder.decode(url, "UTF-8"); //NON-NLS
43  } catch (UnsupportedEncodingException ex) {
44  logger.log(Level.SEVERE, "Could not decode URL " + url, ex); //NON-NLS
45  //should not happen
46  return "";
47  }
48  }
49 
56  public static String encodeURL(String url) {
57  try {
58  return URLEncoder.encode(url, "UTF-8"); //NON-NLS
59  } catch (UnsupportedEncodingException ex) {
60  logger.log(Level.SEVERE, "Could not encode URL " + url, ex); //NON-NLS
61  //should not happen
62  return "";
63  }
64  }
65 
71  public static String escapeHtml(String toEscape) {
72  return StringEscapeUtils.escapeHtml4(toEscape);
73  }
74 
80  public static String unEscapeHtml(String toUnescape) {
81  return StringEscapeUtils.unescapeHtml4(toUnescape);
82  }
83 }
static String escapeHtml(String toEscape)
Definition: EscapeUtil.java:71
static String unEscapeHtml(String toUnescape)
Definition: EscapeUtil.java:80
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.