From 4c0f3cfa6c1d6095e668763965972653cbd66e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Wed, 28 Aug 2024 14:57:20 +0200 Subject: [PATCH] SEBWIN-934: Ensured window title of active application is always current and fixed encoding of screen shot metadata. --- .../Applications/ApplicationMonitor.cs | 8 +++++++- .../Service/Requests/ScreenShotRequest.cs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs b/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs index 79d656ab..0fbd52db 100644 --- a/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs +++ b/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs @@ -98,7 +98,13 @@ namespace SafeExamBrowser.Monitoring.Applications if (activeWindow != default && TryGetProcessFor(activeWindow, out var process)) { - application = new ActiveApplication(process, new Window { Handle = activeWindow.Handle, Title = activeWindow.Title }); + var window = new Window + { + Handle = activeWindow.Handle, + Title = nativeMethods.GetWindowTitle(activeWindow.Handle) + }; + + application = new ActiveApplication(process, window); } return application != default; diff --git a/SafeExamBrowser.Proctoring/ScreenProctoring/Service/Requests/ScreenShotRequest.cs b/SafeExamBrowser.Proctoring/ScreenProctoring/Service/Requests/ScreenShotRequest.cs index 19c75a9a..bca0e584 100644 --- a/SafeExamBrowser.Proctoring/ScreenProctoring/Service/Requests/ScreenShotRequest.cs +++ b/SafeExamBrowser.Proctoring/ScreenProctoring/Service/Requests/ScreenShotRequest.cs @@ -7,6 +7,7 @@ */ using System; +using System.Net; using System.Net.Http; using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Proctoring.ScreenProctoring.Data; @@ -24,7 +25,7 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Service.Requests internal bool TryExecute(MetaData metaData, ScreenShot screenShot, string sessionId, out int health, out string message) { var imageFormat = (Header.IMAGE_FORMAT, ToString(screenShot.Format)); - var metdataJson = (Header.METADATA, metaData.ToJson()); + var metdataJson = (Header.METADATA, WebUtility.UrlEncode(metaData.ToJson())); var timestamp = (Header.TIMESTAMP, screenShot.CaptureTime.ToUnixTimestamp().ToString()); var url = api.ScreenShotEndpoint.Replace(Api.SESSION_ID, sessionId); var success = TryExecute(HttpMethod.Post, url, out var response, screenShot.Data, ContentType.OCTET_STREAM, Authorization, imageFormat, metdataJson, timestamp);