SEBWIN-592, #421: Fixed crash caused by non-ASCII characters (e.g. Hebrew) in client log file path.
This commit is contained in:
		
							parent
							
								
									561e14822d
								
							
						
					
					
						commit
						3f2342a3d3
					
				
					 2 changed files with 25 additions and 18 deletions
				
			
		|  | @ -9,6 +9,7 @@ | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Diagnostics; | using System.Diagnostics; | ||||||
|  | using System.Text; | ||||||
| using SafeExamBrowser.Applications; | using SafeExamBrowser.Applications; | ||||||
| using SafeExamBrowser.Browser; | using SafeExamBrowser.Browser; | ||||||
| using SafeExamBrowser.Client.Communication; | using SafeExamBrowser.Client.Communication; | ||||||
|  | @ -175,27 +176,32 @@ namespace SafeExamBrowser.Client | ||||||
| 		{ | 		{ | ||||||
| 			var args = Environment.GetCommandLineArgs(); | 			var args = Environment.GetCommandLineArgs(); | ||||||
| 			var hasFive = args?.Length >= 5; | 			var hasFive = args?.Length >= 5; | ||||||
|  | 			var valid = false; | ||||||
| 
 | 
 | ||||||
| 			if (hasFive) | 			if (hasFive) | ||||||
| 			{ | 			{ | ||||||
| 				var hasLogfilePath = Uri.TryCreate(args[1], UriKind.Absolute, out Uri filePath) && filePath.IsFile; | 				var logFilePath = Encoding.UTF8.GetString(Convert.FromBase64String(args[1])); | ||||||
| 				var hasLogLevel = Enum.TryParse(args[2], out LogLevel level); | 				var hasLogFilePath = Uri.TryCreate(logFilePath, UriKind.Absolute, out var filePath) && filePath.IsFile; | ||||||
| 				var hasHostUri = Uri.TryCreate(args[3], UriKind.Absolute, out Uri hostUri) && hostUri.IsWellFormedOriginalString(); | 				var hasLogLevel = Enum.TryParse(args[2], out LogLevel logLevel); | ||||||
| 				var hasAuthenticationToken = Guid.TryParse(args[4], out Guid token); | 				var hasHostUri = Uri.TryCreate(args[3], UriKind.Absolute, out var runtimeHostUri) && runtimeHostUri.IsWellFormedOriginalString(); | ||||||
|  | 				var hasAuthenticationToken = Guid.TryParse(args[4], out var authenticationToken); | ||||||
| 
 | 
 | ||||||
| 				if (hasLogfilePath && hasLogLevel && hasHostUri && hasAuthenticationToken) | 				if (hasLogFilePath && hasLogLevel && hasHostUri && hasAuthenticationToken) | ||||||
| 				{ | 				{ | ||||||
| 					logFilePath = args[1]; | 					this.authenticationToken = authenticationToken; | ||||||
| 					logLevel = level; | 					this.logFilePath = logFilePath; | ||||||
| 					runtimeHostUri = args[3]; | 					this.logLevel = logLevel; | ||||||
| 					authenticationToken = token; | 					this.runtimeHostUri = args[3]; | ||||||
| 					uiMode = args.Length == 6 && Enum.TryParse(args[5], out uiMode) ? uiMode : UserInterfaceMode.Desktop; | 					this.uiMode = args.Length == 6 && Enum.TryParse(args[5], out uiMode) ? uiMode : UserInterfaceMode.Desktop; | ||||||
| 
 | 
 | ||||||
| 					return; | 					valid = true; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			throw new ArgumentException("Invalid arguments! Required: SafeExamBrowser.Client.exe <logfile path> <log level> <host URI> <token>"); | 			if (!valid) | ||||||
|  | 			{ | ||||||
|  | 				throw new ArgumentException("Invalid arguments! Required: SafeExamBrowser.Client.exe <logfile path> <log level> <host URI> <token>"); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		private void InitializeLogging() | 		private void InitializeLogging() | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| using System; | using System; | ||||||
|  | using System.Text; | ||||||
| using System.Threading; | using System.Threading; | ||||||
| using SafeExamBrowser.Communication.Contracts; | using SafeExamBrowser.Communication.Contracts; | ||||||
| using SafeExamBrowser.Communication.Contracts.Events; | using SafeExamBrowser.Communication.Contracts.Events; | ||||||
|  | @ -23,11 +24,11 @@ namespace SafeExamBrowser.Runtime.Operations | ||||||
| { | { | ||||||
| 	internal class ClientOperation : SessionOperation | 	internal class ClientOperation : SessionOperation | ||||||
| 	{ | 	{ | ||||||
| 		private int timeout_ms; | 		private readonly ILogger logger; | ||||||
| 		private ILogger logger; | 		private readonly IProcessFactory processFactory; | ||||||
| 		private IProcessFactory processFactory; | 		private readonly IProxyFactory proxyFactory; | ||||||
| 		private IProxyFactory proxyFactory; | 		private readonly IRuntimeHost runtimeHost; | ||||||
| 		private IRuntimeHost runtimeHost; | 		private readonly int timeout_ms; | ||||||
| 
 | 
 | ||||||
| 		private IProcess ClientProcess | 		private IProcess ClientProcess | ||||||
| 		{ | 		{ | ||||||
|  | @ -99,7 +100,7 @@ namespace SafeExamBrowser.Runtime.Operations | ||||||
| 		{ | 		{ | ||||||
| 			var authenticationToken = Context.Next.ClientAuthenticationToken.ToString("D"); | 			var authenticationToken = Context.Next.ClientAuthenticationToken.ToString("D"); | ||||||
| 			var executablePath = Context.Next.AppConfig.ClientExecutablePath; | 			var executablePath = Context.Next.AppConfig.ClientExecutablePath; | ||||||
| 			var logFilePath = $"{'"' + Context.Next.AppConfig.ClientLogFilePath + '"'}";
 | 			var logFilePath = $"{'"' + Convert.ToBase64String(Encoding.UTF8.GetBytes(Context.Next.AppConfig.ClientLogFilePath)) + '"'}";
 | ||||||
| 			var logLevel = Context.Next.Settings.LogLevel.ToString(); | 			var logLevel = Context.Next.Settings.LogLevel.ToString(); | ||||||
| 			var runtimeHostUri = Context.Next.AppConfig.RuntimeAddress; | 			var runtimeHostUri = Context.Next.AppConfig.RuntimeAddress; | ||||||
| 			var uiMode = Context.Next.Settings.UserInterfaceMode.ToString(); | 			var uiMode = Context.Next.Settings.UserInterfaceMode.ToString(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Damian Büchel
						Damian Büchel