Skip to content

Incorrect CLJS deserialization #11

@RokLenarcic

Description

@RokLenarcic
(incognito.edn/read-string-safe {} "#uuid \"ef99b66f-f53b-4ad3-9872-8b8f16f61188\"")
=> #incognito.base.IncognitoTaggedLiteral{:tag uuid, :value "ef99b66f-f53b-4ad3-9872-8b8f16f61188"}
(binding [cljs.reader/*tag-table* (atom (merge {"incognito.base.IncognitoTaggedLiteral"
                                                       (partial incognito-reader read-handlers)}
                                                      ;; HACKY reconstruct vanilla tag-table
                                                      (select-keys @cljs.reader/*tag-table*
                                                                   #{"inst" "uuid" "queue"})))
                 cljs.reader/*default-data-reader-fn*
                 (atom (fn [tag value]
                         (incognito-reader read-handlers {:tag tag :value value})))]
         (read-string s))
         

Even though the keys in reader map are symbols in CLJ and a quick glance at the code tells you that they are in CLJS as well. (select-keys @cljs.reader/*tag-table* #{"inst" "uuid" "queue"}) produces an empty map. Also it would be much neater code (without those bindings), if you just used cljs.tools.reader.edn/read-string directly, which takes readers as a parameter rather than from a global. All read-string does is call it anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions