From eab6460eeae49f9aa16dd3010c6065e6af305f85 Mon Sep 17 00:00:00 2001 From: Ty Satrang Date: Thu, 10 May 2018 15:46:55 -0700 Subject: [PATCH] Escape/unescape Escape prior to sending to DB, unescape prior to displaying in UI --- ChatServiceLambdaFunctions/ZombiePostMessage.js | 2 +- S3WebApp/S3/modules/chat/chatPanel.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChatServiceLambdaFunctions/ZombiePostMessage.js b/ChatServiceLambdaFunctions/ZombiePostMessage.js index 6af8c4d..f5b68e7 100644 --- a/ChatServiceLambdaFunctions/ZombiePostMessage.js +++ b/ChatServiceLambdaFunctions/ZombiePostMessage.js @@ -19,7 +19,7 @@ exports.handler = function(event, context) { if(event.message == null || event.message == 'null' || event.name == null || event.name == 'null') { return context.fail("Message and Name cannot be null"); } else { - message = event.message; + message = escape(event.message); from = event.name; } diff --git a/S3WebApp/S3/modules/chat/chatPanel.js b/S3WebApp/S3/modules/chat/chatPanel.js index e585f05..c8a33ee 100644 --- a/S3WebApp/S3/modules/chat/chatPanel.js +++ b/S3WebApp/S3/modules/chat/chatPanel.js @@ -27,7 +27,9 @@ angular.module('chatApp.chatPanel', ['chatApp.chatMessages']) apigClient.zombieMessageGet(params, body, additionalParams) .then(function(result){ if($rootScope.chatting) { - //console.log('result: ' + result.data.messages); + result.data.messages.forEach(element => { + element.message = unescape(element.message); + }); $scope.messages = result.data.messages; } else {