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

Storing strings with SERIALIZED_MARKER at the beginning fails #63

Closed
jviereck opened this issue Feb 15, 2014 · 0 comments
Closed

Storing strings with SERIALIZED_MARKER at the beginning fails #63

jviereck opened this issue Feb 15, 2014 · 0 comments

Comments

@jviereck
Copy link
Contributor

Assuming a developer wants to store the string:

str = "'__lfsc__:hello world";

in localForage/WebSQL driver, the string can be saved BUT it cannot be read out. This is, as the marker makes the WebSQL driver think the content is serialized and tries to pass hello world to the JSON.parse(...) method - which fails.

An easy fix is to prefix all strings stored in the WebSQL driver and not just the ones that serialized:

// Marker used here:
//   s: ^= String
//   o: ^= Object
localforage.setItem('foo') // -> gets stored as "s:foo" << string
localforage.setItem({hello: "world"}) // -> gets stored as 'o:{"hello":"world"}'
@tofumatt tofumatt added this to the Binary data support milestone Mar 19, 2014
tofumatt added a commit that referenced this issue Mar 19, 2014
tofumatt added a commit that referenced this issue Mar 19, 2014
Adds support for ArrayBuffer, Blob, and most kinds of TypedArrays
to all drivers. Relies on some hairy code (that could be further refactored)
for localStorage and WebSQL, but the point is everything checks out.

PhantomJS seems to have problems with the Blob test; while I'm hesitant to
skip tests, it DOES work fine in Safari, which is the target there, so I'm
going to look into it but commit this work for now, as it's very useful.

* Fix #28
* Fix #30
* Fix #40
* Fix #63

This partially addresses #69, as it allows for Blob storage, but doesn't
address the issue of extremely large files, which neither localStorage nor
WebSQL will support (their limits are too low).
tofumatt added a commit that referenced this issue Mar 19, 2014
Adds support for ArrayBuffer, Blob, and most kinds of TypedArrays
to all drivers. Relies on some hairy code (that could be further refactored)
for localStorage and WebSQL, but the point is everything checks out.

PhantomJS seems to have problems with the Blob test; while I'm hesitant to
skip tests, it DOES work fine in Safari, which is the target there, so I'm
going to look into it but commit this work for now, as it's very useful.

* Fix #28
* Fix #30
* Fix #40
* Fix #63

This partially addresses #69, as it allows for Blob storage, but doesn't
address the issue of extremely large files, which neither localStorage nor
WebSQL will support (their limits are too low).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants