changeset 239:6b4ad6ccc48e

Change the specification of str_b64_decode so that it matches the way how polarssl handles base64 decoding.
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 28 Mar 2014 14:20:08 +0000
parents dd417a2ff9cd
children c05e126b0b9e
files common/strhelp.h ui/tests/commontest.cpp
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/common/strhelp.h	Fri Mar 28 14:18:53 2014 +0000
+++ b/common/strhelp.h	Fri Mar 28 14:20:08 2014 +0000
@@ -84,6 +84,14 @@
  * The memory allocated for dest needs to be free'd by the
  * caller.
  *
+ * _Input warning:_
+ * If the input contains invalid base64 characters an error
+ * is returned.
+ *
+ * If the input is invalid base64 but consists of valid
+ * base64 characters _no error_ is returned and dst contains
+ * the valid input up to the error.
+ *
  * @param [out] dst Pointer to the destination. Needs to be NULL
  * @param [out] dst_size Size allocated for the destination.
  * @param [in] src Pointer to the base64 encoded data.
--- a/ui/tests/commontest.cpp	Fri Mar 28 14:18:53 2014 +0000
+++ b/ui/tests/commontest.cpp	Fri Mar 28 14:20:08 2014 +0000
@@ -12,9 +12,8 @@
     int ret = -1;
     ret = str_base64_decode(&data, &data_size, (char *)foo, 5);
 
-    QVERIFY(ret != 0);
-    QVERIFY(data == NULL);
-    QVERIFY(data_size == 0);
+    QVERIFY(ret == 0);
+    QVERIFY(data == QString::fromLatin1("foo"));
     free(data);
 }
 

http://wald.intevation.org/projects/trustbridge/