mean-expert-official / loopback-sdk-builder

Tool for auto-generating Software Development Kits (SDKs) for LoopBack
Other
399 stars 178 forks source link

"JSON Parse error: Unterminated string" only on iOS - broken string in $LoopBackSDK$user #556

Closed thiagovito closed 3 years ago

thiagovito commented 6 years ago

What type of issue are you creating?

What version of this module are you using?

Write other if any: 2.1.2

Please add a description for your issue:

Guys,

We experienced a bug that happens only on iOS (Safari and Chrome). It happens when trying to store cookie with special characters such as (àáâãèéê, etc).

The error we get is "JSON Parse error: Unterminated string". We get this problem because if there is any of these characters the JSON string brakes in: $LoopBackSDK$user

So to solve that we have changed the following file: sdk/storage/stcookie.browser.ts

we have added: encodeURI(value) in the set method

and decodeURI(value) in parse method.

So that cookies are saved with special characters

PhilFlash commented 6 years ago

Same problem on IOS

jonathan-casarrubias commented 6 years ago

@thiagovito thanks for reaching out, hey so would you mind to send a PR to development with the patches you did to make it work.

I can publish that with the next version 2.2.0 which is about to be published.

Cheers Jon