Fix an error when storing UTF-8 data to DBI session store.

This commit is contained in:
Eitaro Fukamachi 2015-11-19 18:05:04 +09:00
parent 114b513c89
commit 4f07c50b6c
2 changed files with 10 additions and 4 deletions

View file

@ -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))))

View file

@ -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
@ -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)