Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nkbt opened this issue Jun 10, 2016 · 4 comments
Open

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

nkbt opened this issue Jun 10, 2016 · 4 comments

Comments

@nkbt
Copy link

nkbt commented Jun 10, 2016

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.

@glenjamin
Copy link

Are you able to reproduce with a smaller example?

@nkbt
Copy link
Author

nkbt commented Jun 10, 2016

I removed all reducers except one for routing. It had only plain js objects. Same issue persists when I have backslash in the url.

Not something urgent here for me.
Mostly checking if anyone else had similar issue.

Ps: I am leaving roday for holidays otherwise would definitely Investigate further and PR. Well, will do when I'm back if nothing comes up

@glenjamin
Copy link

I had a go at this using just transit, I can't seem to get it to produce a \s.

Can you provide some sample code that passes an object and results in a broken string?

@nkbt
Copy link
Author

nkbt commented Aug 18, 2016

Must be related to #23 too.

Cross-ref to related comment
glenjamin/transit-immutable-js#25 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants