Bug 1484876 - Part 6: Truncate the tracking URIs in the anti-tracking logs to 128 characters since they may be really long; r=francois
☠☠ backed out by 41ebcb085bb0 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 22 Aug 2018 09:07:00 -0400
changeset 487927 e80737d6af552187ffeb8099c8d6fd936febed5e
parent 487926 b1cb63d8c8bb98823dab57773d150178f19e694b
child 487928 41ebcb085bb01e54c1a7eea9e794cde45afbe734
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1484876
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1484876 - Part 6: Truncate the tracking URIs in the anti-tracking logs to 128 characters since they may be really long; r=francois
toolkit/components/antitracking/AntiTrackingCommon.cpp
--- a/toolkit/components/antitracking/AntiTrackingCommon.cpp
+++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ -26,23 +26,25 @@
 #include "prtime.h"
 
 #define ANTITRACKING_PERM_KEY "3rdPartyStorage"
 
 using namespace mozilla;
 using mozilla::dom::ContentChild;
 
 static LazyLogModule gAntiTrackingLog("AntiTracking");
+static const nsCString::size_type sMaxSpecLength = 128;
 
 #define LOG(format) MOZ_LOG(gAntiTrackingLog, mozilla::LogLevel::Debug, format)
 
 #define LOG_SPEC(format, uri)                                                 \
   PR_BEGIN_MACRO                                                              \
     if (MOZ_LOG_TEST(gAntiTrackingLog, mozilla::LogLevel::Debug)) {           \
       nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)"));                   \
+      _specStr.Truncate(std::min(_specStr.Length(), sMaxSpecLength));         \
       if (uri) {                                                              \
         _specStr = uri->GetSpecOrDefault();                                   \
       }                                                                       \
       const char* _spec = _specStr.get();                                     \
       LOG(format);                                                            \
     }                                                                         \
   PR_END_MACRO