From 6481ec4db0fac0af63308131ac69acb658f5cd3f Mon Sep 17 00:00:00 2001 From: Tony Anziano Date: Mon, 15 Jul 2019 16:48:02 -0700 Subject: [PATCH] Fixed issue where html errors were being displayed incorrectly. --- CHANGELOG.md | 3 +++ .../client/src/ui/editor/emulator/parts/log/logEntry.tsx | 7 +++++++ packages/app/main/src/restServer.ts | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3965426f..e64d2338e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## Fixed +- [client] Fixed issue where html errors were being displayed incorrectly in PR [1687](https://github.com/microsoft/BotFramework-Emulator/pull/1687/files) + ## v4.5.1 - 2019 - 07 - 13 ## Fixed - [main] Fixed an issue where uploaded attachments weren't being encoded and decoded properly in PR [1678](https://github.com/microsoft/BotFramework-Emulator/pull/1678) diff --git a/packages/app/client/src/ui/editor/emulator/parts/log/logEntry.tsx b/packages/app/client/src/ui/editor/emulator/parts/log/logEntry.tsx index 6b01d6bb3..4e1e448a8 100644 --- a/packages/app/client/src/ui/editor/emulator/parts/log/logEntry.tsx +++ b/packages/app/client/src/ui/editor/emulator/parts/log/logEntry.tsx @@ -268,6 +268,13 @@ export class LogEntry extends React.Component { if (typeof body === 'string') { try { obj = JSON.parse(body); + // html responses come over as doubly stringified e.g.: """" and + // calling JSON.parse will turn them into a standard string; + // we want to assign the html to a property so that the string isn't expanded + // out into a giant object with one key per character + if (typeof obj === 'string') { + obj = { value: obj }; + } } catch (e) { obj = body; } diff --git a/packages/app/main/src/restServer.ts b/packages/app/main/src/restServer.ts index 74c00c685..1acbbdbed 100644 --- a/packages/app/main/src/restServer.ts +++ b/packages/app/main/src/restServer.ts @@ -130,10 +130,17 @@ export class RestServer { level = LogLevel.Error; } + let responseHeaders; + try { + responseHeaders = res.headers(); + } catch (e) { + responseHeaders = undefined; + } + emulatorApplication.mainWindow.logService.logToChat( conversationId, networkRequestItem(facility, (req as any)._body, req.headers, req.method, req.url), - networkResponseItem((res as any)._data, res.headers, res.statusCode, res.statusMessage, req.url), + networkResponseItem((res as any)._data, responseHeaders, res.statusCode, res.statusMessage, req.url), textItem(level, `${facility}.${routeName}`) ); };