| File: | root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/components/antitracking/./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp |
| Warning: | line 25, column 12 Value stored to 'rv' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | |
| 5 | #include "URLDecorationStripper.h" |
| 6 | |
| 7 | #include "mozilla/Components.h" |
| 8 | #include "mozilla/Preferences.h" |
| 9 | #include "nsCharSeparatedTokenizer.h" |
| 10 | #include "nsIEffectiveTLDService.h" |
| 11 | #include "nsIURI.h" |
| 12 | #include "nsIURIMutator.h" |
| 13 | #include "nsURLHelper.h" |
| 14 | |
| 15 | namespace { |
| 16 | static const char* kPrefName = |
| 17 | "privacy.restrict3rdpartystorage.url_decorations"; |
| 18 | } // namespace |
| 19 | |
| 20 | namespace mozilla { |
| 21 | |
| 22 | nsresult URLDecorationStripper::StripTrackingIdentifiers(nsIURI* aURI, |
| 23 | nsACString& aOutSpec) { |
| 24 | nsAutoCString tokenList; |
| 25 | nsresult rv = Preferences::GetCString(kPrefName, tokenList); |
Value stored to 'rv' during its initialization is never read | |
| 26 | ToLowerCase(tokenList); |
| 27 | |
| 28 | nsAutoCString path; |
| 29 | rv = aURI->GetPathQueryRef(path); |
| 30 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp" , 30); return rv; } } while (false); |
| 31 | ToLowerCase(path); |
| 32 | |
| 33 | int32_t queryBegins = path.FindChar('?'); |
| 34 | // Only positive values are valid since the path must begin with a '/'. |
| 35 | if (queryBegins > 0) { |
| 36 | for (const nsACString& token : tokenList.Split(' ')) { |
| 37 | if (token.IsEmpty()) { |
| 38 | continue; |
| 39 | } |
| 40 | |
| 41 | nsAutoCString value; |
| 42 | if (URLParams::Extract(Substring(path, queryBegins + 1), token, value) && |
| 43 | !value.IsVoid()) { |
| 44 | // Tracking identifier found in the URL! |
| 45 | return StripToRegistrableDomain(aURI, aOutSpec); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return aURI->GetSpec(aOutSpec); |
| 51 | } |
| 52 | |
| 53 | nsresult URLDecorationStripper::StripToRegistrableDomain(nsIURI* aURI, |
| 54 | nsACString& aOutSpec) { |
| 55 | NS_MutateURI mutator(aURI); |
| 56 | mutator.SetPathQueryRef(""_ns).SetUserPass(""_ns); |
| 57 | |
| 58 | nsCOMPtr<nsIEffectiveTLDService> etldService = |
| 59 | mozilla::components::EffectiveTLD::Service(); |
| 60 | NS_ENSURE_TRUE(etldService, NS_ERROR_FAILURE)do { if ((__builtin_expect(!!(!(etldService)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "etldService" ") failed" , nullptr, "./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp" , 60); return NS_ERROR_FAILURE; } } while (false); |
| 61 | nsAutoCString baseDomain; |
| 62 | nsresult rv = etldService->GetBaseDomain(aURI, 0, baseDomain); |
| 63 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { |
| 64 | mutator.SetHost(baseDomain); |
| 65 | } else { |
| 66 | // If this is an IP address or something like "localhost", ignore the error. |
| 67 | if (rv != NS_ERROR_HOST_IS_IP_ADDRESS && |
| 68 | rv != NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) { |
| 69 | return rv; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | nsCOMPtr<nsIURI> uri; |
| 74 | rv = mutator.Finalize(uri); |
| 75 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp" , 75); return rv; } } while (false); |
| 76 | return uri->GetSpec(aOutSpec); |
| 77 | } |
| 78 | |
| 79 | } // namespace mozilla |