Skip to content

Commit

Permalink
Fix an error when storing UTF-8 data to DBI session store.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Nov 19, 2015
1 parent 114b513 commit 4f07c50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions lack-session-store-dbi.asd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:depends-on (:lack-middleware-session
:dbi
:marshal
:trivial-utf-8
:cl-base64)
:components ((:file "src/middleware/session/store/dbi"))
:in-order-to ((test-op (test-op t-lack-session-store-dbi))))
13 changes: 9 additions & 4 deletions src/middleware/session/store/dbi.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
:marshal
:unmarshal)
(:import-from :cl-base64
:base64-string-to-string
:string-to-base64-string)
:base64-string-to-usb8-array
:usb8-array-to-base64-string)
(:import-from :trivial-utf-8
:string-to-utf-8-bytes
:utf-8-bytes-to-string)
(:export :dbi-store
:make-dbi-store
:fetch-session
Expand All @@ -19,9 +22,11 @@
(defstruct (dbi-store (:include store))
(connector nil :type function)
(serializer (lambda (data)
(string-to-base64-string (prin1-to-string (marshal data)))))
(usb8-array-to-base64-string
(string-to-utf-8-bytes (prin1-to-string (marshal data))))))
(deserializer (lambda (data)
(unmarshal (read-from-string (base64-string-to-string data)))))
(unmarshal (read-from-string
(utf-8-bytes-to-string (base64-string-to-usb8-array data))))))
(table-name "sessions"))

(defmethod fetch-session ((store dbi-store) sid)
Expand Down

0 comments on commit 4f07c50

Please sign in to comment.