Skip to content

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

@nkbt

Description

@nkbt

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"
]

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

I checked with transit-immutable-js glenjamin/transit-immutable-js#20 and it seems like upstream bug, so opening here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions