Autopsy  4.19.3
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.text.StringEscapeUtils;
26 
30 public class EscapeUtil {
31 
32  private static final Logger logger = Logger.getLogger(EscapeUtil.class.getName());
33 
41  public static String decodeURL(String url) {
42  try {
43  return URLDecoder.decode(url, "UTF-8"); //NON-NLS
44  } catch (UnsupportedEncodingException ex) {
45  logger.log(Level.SEVERE, "Could not decode URL " + url, ex); //NON-NLS
46  //should not happen
47  return "";
48  }
49  }
50 
58  public static String encodeURL(String url) {
59  try {
60  return URLEncoder.encode(url, "UTF-8"); //NON-NLS
61  } catch (UnsupportedEncodingException ex) {
62  logger.log(Level.SEVERE, "Could not encode URL " + url, ex); //NON-NLS
63  //should not happen
64  return "";
65  }
66  }
67 
75  public static String escapeHtml(String toEscape) {
76  return StringEscapeUtils.escapeHtml4(toEscape);
77  }
78 
86  public static String unEscapeHtml(String toUnescape) {
87  return StringEscapeUtils.unescapeHtml4(toUnescape);
88  }
89 }
static String escapeHtml(String toEscape)
Definition: EscapeUtil.java:75
static String decodeURL(String url)
Definition: EscapeUtil.java:41
static String unEscapeHtml(String toUnescape)
Definition: EscapeUtil.java:86
static String encodeURL(String url)
Definition: EscapeUtil.java:58
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.