static String decodeURL(const String& string, const TextEncoding& encoding) { String workingString = string; workingString.replace('+', ' '); workingString = decodeURLEscapeSequences(workingString); CString workingStringUTF8 = workingString.utf8(); String decodedString = encoding.decode(workingStringUTF8.data(), workingStringUTF8.length()); // FIXME: Is this check necessary? if (decodedString.isEmpty()) return canonicalize(workingString); return canonicalize(decodedString); }
String XSSAuditor::decodeURL(const String& string, const TextEncoding& encoding, bool decodeEntities, bool decodeURLEscapeSequencesTwice) { String result; String url = string; url.replace('+', ' '); result = decodeURLEscapeSequences(url); CString utf8Url = result.utf8(); String decodedResult = encoding.decode(utf8Url.data(), utf8Url.length()); if (!decodedResult.isEmpty()) result = decodedResult; if (decodeURLEscapeSequencesTwice) { result = decodeURLEscapeSequences(result); utf8Url = result.utf8(); decodedResult = encoding.decode(utf8Url.data(), utf8Url.length()); if (!decodedResult.isEmpty()) result = decodedResult; } if (decodeEntities) result = decodeHTMLEntities(result); return result; }