Skip to content

Commit 8a4bd4a

Browse files
committed
Double quotes are ignored when encrypting primitive types
1 parent 6413ce7 commit 8a4bd4a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/com/mastercard/developer/encryption/FieldLevelEncryption.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ private static void encryptPayloadPath(DocumentContext payloadContext, String js
124124

125125
// Encrypt data at the given JSON path
126126
String inJsonString = sanitizeJson(inJsonElement.toString());
127+
if (inJsonElement.isJsonPrimitive() && inJsonString.startsWith("\"")) {
128+
// "value" => value
129+
inJsonString = inJsonString.substring(1, inJsonString.length() - 1);
130+
}
127131
byte[] inJsonBytes = null;
128132
try {
129133
inJsonBytes = inJsonString.getBytes(StandardCharsets.UTF_8.name());

0 commit comments

Comments
 (0)