about summary refs log tree commit diff
path: root/web/panettone/src/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'web/panettone/src/util.lisp')
-rw-r--r--web/panettone/src/util.lisp8
1 files changed, 8 insertions, 0 deletions
diff --git a/web/panettone/src/util.lisp b/web/panettone/src/util.lisp
index 9fd9ceaa79a4..2abedf7b8fbb 100644
--- a/web/panettone/src/util.lisp
+++ b/web/panettone/src/util.lisp
@@ -5,3 +5,11 @@
    (when-let ((str (uiop:getenvp var)))
      (try-parse-integer str))
    default))
+
+(defun add-missing-base64-padding (s)
+  "Add any missing padding characters to the (un-padded) base64 string `S', such
+that it can be successfully decoded by the `BASE64' package"
+  ;; I apologize
+  (let* ((needed-padding (mod (length s) 4))
+         (pad-chars (if (zerop needed-padding) 0 (- 4 needed-padding))))
+    (format nil "~A~v@{~A~:*~}" s pad-chars "=")))