Skip to content

Commit

Permalink
Added code to check for base64 encoded before writing to DeadLetter C…
Browse files Browse the repository at this point in the history
…osmos container
  • Loading branch information
manu-govind committed Jun 13, 2024
1 parent 4ae75ae commit 1dd3dee
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class ReportManager: KoinComponent {
this.dispositionType= dispositionType.toString()
this.contentType = contentType
this.deadLetterReasons= deadLetterReasons
if (contentType?.lowercase() == "json" && !isNullOrEmpty(content)) {
if (contentType?.lowercase() == "json" && !isNullOrEmpty(content) && !isBase64Encoded(content.toString())) {
val typeObject = object : TypeToken<HashMap<*, *>?>() {}.type
val jsonMap: Map<String, Any> = gson.fromJson(Gson().toJson(content, MutableMap::class.java).toString(), typeObject)
this.content = jsonMap
Expand Down Expand Up @@ -260,6 +260,11 @@ class ReportManager: KoinComponent {
}
}

private fun isBase64Encoded(value: String): Boolean {
val base64Pattern = "^[A-Za-z0-9+/]+={0,2}$"
return value.matches(base64Pattern.toRegex())
}

fun createReportItem(uploadId: String?, reportId:String, reportType:Any) : String{

var responseReportId = ""
Expand Down

0 comments on commit 1dd3dee

Please sign in to comment.