gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Tolerating "noise data" into subject l


From: gnunet
Subject: [libeufin] branch master updated: Tolerating "noise data" into subject lines.
Date: Thu, 11 Jun 2020 14:13:04 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 0b14507  Tolerating "noise data" into subject lines.
0b14507 is described below

commit 0b14507fe0609b0ca317318f11234d6d8c35bdc8
Author: MS <ms@taler.net>
AuthorDate: Thu Jun 11 14:11:12 2020 +0200

    Tolerating "noise data" into subject lines.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 10 +++++++---
 nexus/src/test/kotlin/SubjectNormalization.kt      |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index d4c1da1..16c30ed 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -221,10 +221,14 @@ fun paymentFailed(entry: RawBankTransactionEntity): 
Boolean {
     return false
 }
 
-// Tries to extract a valid PUB from the raw subject
-// line, as that was communicated by the originating bank.
+// Tries to extract a valid PUB from the raw subject line
 fun normalizeSubject(rawSubject: String): String {
-    return rawSubject
+    val re = "\\b[a-z0-9A-Z]{52}\\b".toRegex()
+    val result = 
re.find("1ENVZ6EYGB6Z509KRJ6E59GK1EQXZF8XXNY9SN33C2KDGSHV9KA0")
+    if (result == null) throw NexusError(
+        HttpStatusCode.BadRequest, "Reserve pub not found in subject: 
${rawSubject}"
+    )
+    return result.value
 }
 
 fun getTalerFacadeState(fcid: String): TalerFacadeStateEntity {
diff --git a/nexus/src/test/kotlin/SubjectNormalization.kt 
b/nexus/src/test/kotlin/SubjectNormalization.kt
index efda187..63f02d2 100644
--- a/nexus/src/test/kotlin/SubjectNormalization.kt
+++ b/nexus/src/test/kotlin/SubjectNormalization.kt
@@ -8,5 +8,6 @@ class SubjectNormalization {
     fun testBeforeAndAfter() {
         val mereValue = "1ENVZ6EYGB6Z509KRJ6E59GK1EQXZF8XXNY9SN33C2KDGSHV9KA0"
         assert(mereValue == normalizeSubject(mereValue))
+        assert(mereValue == normalizeSubject("noise before ${mereValue} noise 
after"))
     }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]