"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "platform/netwerk/base/nsStandardURL.cpp" between
palemoon-29.4.1-source.tar.xz and palemoon-29.4.2-source.tar.xz

About: Pale Moon is a full-featured, optimized browser derived from the code behind the Firefox browser (shares the Unified XUL Platform (UXP)). Source code. Hint (Sept. 15, 2021): The separate application source code tarballs seems no longer available but only tarballs bundled with the underlying UXP platform code (see here).

nsStandardURL.cpp  (palemoon-29.4.1-source.tar.xz):nsStandardURL.cpp  (palemoon-29.4.2-source.tar.xz)
skipping to change at line 557 skipping to change at line 557
} }
uint8_t ipSegments[4]; uint8_t ipSegments[4];
NetworkEndian::writeUint32(ipSegments, ipv4); NetworkEndian::writeUint32(ipSegments, ipv4);
result = nsPrintfCString("%d.%d.%d.%d", ipSegments[0], ipSegments[1], result = nsPrintfCString("%d.%d.%d.%d", ipSegments[0], ipSegments[1],
ipSegments[2], ipSegments[3]); ipSegments[2], ipSegments[3]);
return NS_OK; return NS_OK;
} }
* Returns |true| if |aString| contains only ASCII characters according
* to our CRT.
* @param aString an 8-bit wide string to scan
inline bool IsAsciiString(mozilla::Span<const char> aString) {
for (char c : aString) {
if (!nsCRT::IsAscii(c)) {
return false;
return true;
nsresult nsresult
nsStandardURL::NormalizeIDN(const nsCSubstring &host, nsCString &result) nsStandardURL::NormalizeIDN(const nsCSubstring &host, nsCString &result)
{ {
// If host is ACE, then convert to UTF-8. Else, if host is already UTF-8, nsresult rv = NS_ERROR_UNEXPECTED;
// then make sure it is normalized per IDN. // Clear result even if we bail.
// this function returns true if normalization succeeds.
// NOTE: As a side-effect this function sets mHostEncoding. While it would
// be nice to avoid side-effects in this function, the implementation of
// this function is already somewhat bound to the behavior of the
// callsites. Anyways, this function exists to avoid code duplication, so
// side-effects abound :-/
NS_ASSERTION(mHostEncoding == eEncoding_ASCII, "unexpected default encoding"
bool isASCII;
if (!gIDN) { if (!gIDN) {
nsCOMPtr<nsIIDNService> serv(do_GetService(NS_IDNSERVICE_CONTRACTID)); nsCOMPtr<nsIIDNService> serv(do_GetService(NS_IDNSERVICE_CONTRACTID));
if (serv) { if (serv) {
NS_ADDREF(gIDN = serv.get()); NS_ADDREF(gIDN = serv.get());
} }
} }
if (!gIDN) {
result.Truncate(); NS_ASSERTION(mHostEncoding == eEncoding_ASCII, "unexpected default encoding"
nsresult rv = NS_ERROR_UNEXPECTED; );
if (gIDN) {
rv = gIDN->ConvertToDisplayIDN(host, &isASCII, result); bool isASCII;
if (NS_SUCCEEDED(rv) && !isASCII) { nsAutoCString normalized;
mHostEncoding = eEncoding_UTF8;
} // If the input is ASCII, and not ACE encoded, then there's no processing
// needed. This is needed because we want to allow ascii labels longer than
// 64 characters for some schemes.
bool isACE = false;
if (IsAsciiString(host) && NS_SUCCEEDED(gIDN->IsACE(host, &isACE)) && !isACE
) {
result = host;
return NS_OK;
// If the input is an ACE encoded string it MUST be ASCII or it's malformed
// according to the spec.
if (!IsAsciiString(host) && isACE) {
// Even if it's already ACE, we must still call ConvertUTF8toACE in order
// for the input normalization to take place.
rv = gIDN->ConvertUTF8toACE(host, normalized);
if (NS_FAILED(rv)) {
return rv;
// If the ASCII representation doesn't contain the xn-- token then we don't
// need to call ConvertToDisplayIDN as that would not change anything.
if (!StringBeginsWith(normalized, NS_LITERAL_CSTRING("xn--")) &&
normalized.Find(NS_LITERAL_CSTRING(".xn--")) == kNotFound) {
return NS_OK;
// Finally, convert to IDN
rv = gIDN->ConvertToDisplayIDN(normalized, &isASCII, result);
if (NS_SUCCEEDED(rv) && !isASCII) {
mHostEncoding = eEncoding_UTF8;
} }
return rv; return rv;
} }
bool bool
nsStandardURL::ValidIPv6orHostname(const char *host, uint32_t length) nsStandardURL::ValidIPv6orHostname(const char *host, uint32_t length)
{ {
if (!host || !*host) { if (!host || !*host) {
// Should not be NULL or empty string // Should not be NULL or empty string
 End of changes. 5 change blocks. 
21 lines changed or deleted 61 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)