소스 검색

more user agent checking

Scrublord1336 6 년 전
부모
커밋
0ba47f2626
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      src/XUnity.AutoTranslator.Plugin.Core/Web/GoogleTranslateEndpoint.cs

+ 8 - 1
src/XUnity.AutoTranslator.Plugin.Core/Web/GoogleTranslateEndpoint.cs

@@ -113,7 +113,14 @@ namespace XUnity.AutoTranslator.Plugin.Core.Web
                   {
                      var reader = new StringReader( userAgents );
                      var popularUserAgent = reader.ReadLine();
-                     _popularUserAgent = popularUserAgent;
+                     if( popularUserAgent.Length > 30 && popularUserAgent.Length < 300 && popularUserAgent.StartsWith( "Mozilla/5.0" ) )
+                     {
+                        _popularUserAgent = popularUserAgent;
+                     }
+                     else
+                     {
+                        Logger.Current.Warn( "An error occurred while retrieving dynamic user agent. Could not find a user agent in returned html." );
+                     }
                   }
                   else
                   {