glenjamin / transit-immutable-js

Transit serialisation for Immutable.js
MIT License
250 stars 31 forks source link

`\s` is not encoded properly, breaks further fromJSON() #20

Closed nkbt closed 8 years ago

nkbt commented 8 years ago

20160608-133553

20160608-133702

It could be purely transit-js issue, will move to upstream if not the problem of transit-immutable-js

My JSON after encoding looks like this:

[
  "^ ",
  "componentRouter",
  [
    "^ ",
    "pathname",
    "/ddos",
    "hash",
    null,
    "query",
    [
      "^ ",
      "filters",
      "blabla\sqwer"
    ],
    "cleanQuery",
    [
      "^ ",
      "^4",
      "blabla\sqwer"
    ],
    "defaultParams",
    [
      "^ "
    ],
    "routes",
    [
      "^ ",
      "/ddos",
      [
        "^ ",
        "route",
        "/ddos",
        "regex",
        "~^/ddos$",
        "params",
        [
          "^ "
        ]
      ]
    ],
    "currentRoute",
    [
      "^ ",
      "^9",
      "/ddos",
      "^:",
      "~^/ddos$",
      "^;",
      [
        "^ "
      ]
    ],
    "locationType",
    "LOCATION_HISTORY"
  ]
]

Some context: this is universal JS app, I serialize Redux store on a server (partially immutable-js, partially plain objects) and then I am trying to deserialize it in a browser. Accidentally my route had something\something in it, and that \s broke fromJSON() because backslash was not escaped.

Expected value:

[
  "^ ",
  "componentRouter",
  "...cut",
  [
    "query",
    [
      "^ ",
      "filters",
      "blabla\\sqwer"
    ],
    "cleanQuery",
    [
      "^ ",
      "^4",
      "blabla\\sqwer"
    ]
  ],
  "...cut"
]
nkbt commented 8 years ago

\b is ok for some reason. But other combinations like \a, \c fail too.

glenjamin commented 8 years ago

This is almost certainly a problem with upstream - there's nothing in this module that should affect string escaping

nkbt commented 8 years ago

Thanks. Will move it there then On Wed, 8 Jun 2016 at 16:41, Glen Mailer notifications@github.com wrote:

This is almost certainly a problem with upstream - there's nothing in this module that should affect string escaping

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/glenjamin/transit-immutable-js/issues/20#issuecomment-224501589, or mute the thread https://github.com/notifications/unsubscribe/AAKsoGXUp7jNkukKzQ3iyAweGswEOlurks5qJmI-gaJpZM4IwkpD .

nkbt commented 8 years ago

Closing for now, will reopen if not upstream issue.