"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "platform/netwerk/dns/nsIDNService.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).

nsIDNService.cpp  (palemoon-29.4.1-source.tar.xz):nsIDNService.cpp  (palemoon-29.4.2-source.tar.xz)
skipping to change at line 205 skipping to change at line 205
} }
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// Output the result of nameToUnicode even if there were errors // Output the result of nameToUnicode even if there were errors
ICUUtils::AssignUCharArrayToString(outputBuffer, outLen, output); ICUUtils::AssignUCharArrayToString(outputBuffer, outLen, output);
if (flag == eStringPrepIgnoreErrors) { if (flag == eStringPrepIgnoreErrors) {
return NS_OK; return NS_OK;
} }
if (info.errors != 0) { uint32_t ignoredErrors = 0;
if (flag == eStringPrepForDNS) {
ignoredErrors = UIDNA_ERROR_LEADING_HYPHEN | UIDNA_ERROR_TRAILING_HYPHEN |
UIDNA_ERROR_HYPHEN_3_4;
}
if ((info.errors & ~ignoredErrors) != 0) {
if (flag == eStringPrepForDNS) { if (flag == eStringPrepForDNS) {
output.Truncate(); output.Truncate();
} }
rv = NS_ERROR_MALFORMED_URI; rv = NS_ERROR_MALFORMED_URI;
} }
return rv; return rv;
} }
NS_IMETHODIMP nsIDNService::ConvertUTF8toACE(const nsACString & input, nsACStrin g & ace) NS_IMETHODIMP nsIDNService::ConvertUTF8toACE(const nsACString & input, nsACStrin g & ace)
skipping to change at line 312 skipping to change at line 318
if (NS_FAILED(decodeACE(Substring(input, offset, len), decodedBuf, if (NS_FAILED(decodeACE(Substring(input, offset, len), decodedBuf,
flag))) flag)))
_retval.Assign(input); _retval.Assign(input);
else else
_retval.Append(decodedBuf); _retval.Append(decodedBuf);
} }
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;
}
NS_IMETHODIMP nsIDNService::IsACE(const nsACString & input, bool *_retval) NS_IMETHODIMP nsIDNService::IsACE(const nsACString & input, bool *_retval)
{ {
const char *data = input.BeginReading();
uint32_t dataLen = input.Length();
// look for the ACE prefix in the input string. it may occur // look for the ACE prefix in the input string. it may occur
// at the beginning of any segment in the domain name. for // at the beginning of any segment in the domain name. for
// example: "www.xn--ENCODED.com" // example: "www.xn--ENCODED.com"
if (!IsAsciiString(input)) {
const char *p = PL_strncasestr(data, kACEPrefix, dataLen); *_retval = false;
return NS_OK;
*_retval = p && (p == data || *(p - 1) == '.'); }
auto stringContains = [](const nsACString& haystack,
const nsACString& needle) {
return std::search(haystack.BeginReading(), haystack.EndReading(),
needle.BeginReading(),
needle.EndReading()) != haystack.EndReading();
};
*_retval = StringBeginsWith(input, NS_LITERAL_CSTRING("xn--")) ||
(!input.IsEmpty() && input[0] != '.' &&
stringContains(input, NS_LITERAL_CSTRING(".xn--")));
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIDNService::Normalize(const nsACString & input, NS_IMETHODIMP nsIDNService::Normalize(const nsACString & input,
nsACString & output) nsACString & output)
{ {
// protect against bogus input // protect against bogus input
NS_ENSURE_TRUE(IsUTF8(input), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(IsUTF8(input), NS_ERROR_UNEXPECTED);
NS_ConvertUTF8toUTF16 inUTF16(input); NS_ConvertUTF8toUTF16 inUTF16(input);
 End of changes. 4 change blocks. 
8 lines changed or deleted 36 lines changed or added

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