From 3125e0969bab85bd1c832564face55334831375b Mon Sep 17 00:00:00 2001 From: joshijigar <40574340+joshijigar@users.noreply.github.com> Date: Wed, 27 Jun 2018 23:10:04 +0530 Subject: [PATCH] IpnHandler.cs --- AmazonPay/IpnHandler.cs | 3 ++- AmazonPay/SanitizeData.cs | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/AmazonPay/IpnHandler.cs b/AmazonPay/IpnHandler.cs index 00cef90..f86f483 100644 --- a/AmazonPay/IpnHandler.cs +++ b/AmazonPay/IpnHandler.cs @@ -156,7 +156,8 @@ private void LogRequestDetails(NameValueCollection headers, string message) for (int i = 0; i < headers.Count; i++) { - sb.AppendLine("[Key: " + headers.GetKey(i) + ", Value: " + headers.GetValues(headers.GetKey(i))[0] + "]"); + string key = headers.GetKey(i); + sb.AppendLine("[Key: " + key + ", Value: @#" + key +"#@" + headers.GetValues(headers.GetKey(i))[0] + "@#" + key +"#@]"); } // Logging headers LogMessage(sb.ToString(), AmazonPay.SanitizeData.DataType.Text); diff --git a/AmazonPay/SanitizeData.cs b/AmazonPay/SanitizeData.cs index 5e98c61..00f0865 100644 --- a/AmazonPay/SanitizeData.cs +++ b/AmazonPay/SanitizeData.cs @@ -109,8 +109,21 @@ public static string SanitizeGivenData(string data, DataType type) } // Text Data Type else if (type == DataType.Text) - { - returnString = data; + { + foreach (var item in sanitizeList) + { + string maskedValue = "@#" + item + "#@"; + int startIndex = data.IndexOf(maskedValue); + if (startIndex > 0) + { + int endIndex = data.LastIndexOf(maskedValue) + (maskedValue.Length); + int length = endIndex - startIndex; + string value = data.Substring(startIndex, length); + data = data.Replace(value, REMOVED_TEXT); + } + } + System.Text.RegularExpressions.Regex objRegEx = new System.Text.RegularExpressions.Regex("@#[^#@]*#@", System.Text.RegularExpressions.RegexOptions.IgnoreCase); + returnString = objRegEx.Replace(data, ""); } return returnString; }