private static String getUserAgentAgnosticFileName(String fileName, String responseEncoding) throws UnsupportedEncodingException { // let's try to bring the filename to it's baseform by replacing diacritics: if then still there are non-ascii chars, we log an info // message that you might need user-agent-specific mode, and return a utf-8 encoded version. String asciiFileName = EncodingUtils.foldToASCIIReplacer(fileName); // now check whether the asciiFileName really only contains ascii chars: String encodedAsciiFileName = URLEncoder.encode(asciiFileName, responseEncoding != null ? responseEncoding : DEFAULT_ENCODING); if (encodedAsciiFileName.equals(asciiFileName)) { log.debug("Replaced fileName '{}' with its un-accented equivalent '{}'", fileName, asciiFileName); return asciiFileName; } else { log.info("Filename '{}' consists of non latin chars. We have to utf-8 encode the filename, " + " which might be shown with unencoded in some browsers." + " If you want to avoid this, use '{}'. However, this influences reverse proxies.", fileName, USER_AGENT_SPECIFIC_CONTENT_DISPOSITION_FILENAME_ENCODING); return encodedAsciiFileName; } }
String encodedPath = EncodingUtils.getEncodedPath(nodeLocation, servletRequest);
/** * Returns a parsed version of the input. * * @param input the user input * @param allowSingleNonLeadingWildCardPerTerm if there is allowed one wildcard (* or ?) per term (however, still * not allowed as leading for a term) * @param ignore the chars that should not be parsed * @param retainWordBoundaries whether to retain characters such as ~ & ! when they appear in a * token as word boundaries or remove them, see also * {@link #isSpecialChar(char)} * @return the parsed version of the <code>input</code>. When <code>input</code> is <code>null</code>, * <code>null</code> is returned */ public static String parse(final String input, final boolean allowSingleNonLeadingWildCardPerTerm, final char[] ignore, final boolean retainWordBoundaries) { if (input == null) { return null; } String parsed = EncodingUtils.foldToASCIIReplacer(input); parsed = compressWhitespace(parsed); parsed = removeInvalidAndEscapeChars(parsed, allowSingleNonLeadingWildCardPerTerm, ignore, retainWordBoundaries); parsed = removeLeadingOrTrailingOrOperator(parsed); parsed = rewriteNotOperatorsToMinus(parsed); parsed = removeLeadingAndTrailingAndReplaceWithSpaceAndOperators(parsed); log.debug("Rewrote input '{}' to '{}'", input, parsed); return parsed; }