Ver código fonte

PlayerComponent: censor plex token in URLs shown on debug overlay

Vincent Lang 9 anos atrás
pai
commit
fa927679cb
3 arquivos alterados com 7 adições e 2 exclusões
  1. 2 0
      src/player/PlayerComponent.cpp
  2. 2 2
      src/utils/Log.cpp
  3. 3 0
      src/utils/Log.h

+ 2 - 0
src/player/PlayerComponent.cpp

@@ -7,6 +7,7 @@
 #include "settings/SettingsComponent.h"
 #include "system/SystemComponent.h"
 #include "utils/Utils.h"
+#include "utils/Log.h"
 #include "ComponentManager.h"
 #include "settings/SettingsSection.h"
 
@@ -1134,6 +1135,7 @@ static QString get_mpv_osd(mpv_handle *ctx, const QString& property)
     return "-";
   QString r = QString::fromUtf8(s);
   mpv_free(s);
+  Log::CensorAuthTokens(r);
   return r;
 }
 

+ 2 - 2
src/utils/Log.cpp

@@ -59,7 +59,7 @@ static void elidePattern(QString& msg, const QString& substring, int chars)
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-static void processLog(QString& msg)
+void Log::CensorAuthTokens(QString& msg)
 {
   elidePattern(msg, "X-Plex-Token=", 20);
   elidePattern(msg, "X-Plex-Token%3D", 20);
@@ -108,7 +108,7 @@ void Log::Init()
 
   Logger::instance().addDestination(dest);
   Logger::instance().setLoggingLevel(DebugLevel);
-  Logger::instance().setProcessingCallback(processLog);
+  Logger::instance().setProcessingCallback(Log::CensorAuthTokens);
 
   qInstallMessageHandler(qtMessageOutput);
 

+ 3 - 0
src/utils/Log.h

@@ -5,10 +5,13 @@
 #ifndef PLEXMEDIAPLAYER_LOG_H
 #define PLEXMEDIAPLAYER_LOG_H
 
+#include <QString>
+
 namespace Log
 {
   void Init();
   void UpdateLogLevel();
+  void CensorAuthTokens(QString& msg);
 }
 
 #endif //PLEXMEDIAPLAYER_LOG_H