private static String escapeQuotationsInFilename(String filename) {
        if (filename.indexOf('"') == -1 && filename.indexOf('\\') == -1) {
            return filename;
        }
        boolean escaped = false;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < filename.length() ; i++) {
            char c = filename.charAt(i);
            if (!escaped && c == '"') {
                sb.append("\\\"");
            }
            else {
                sb.append(c);
            }
            escaped = (!escaped && c == '\\');
        }
        // Remove backslash at the end..
        if (escaped) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }
Decode the given header field param as described in RFC 5987.
<p>Only the US-ASCII, UTF-8 and ISO-8859-1 charsets are supported.
@param filename the filename
@param charset the charset for the filename
@return the encoded header field param
@see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a>
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ContentDisposition.java