Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15887a8

Browse files
committedFeb 27, 2012
goodbye base64 and IE localStorage bug 🐨
1 parent d6bf1ac commit 15887a8

File tree

2 files changed

+11
-143
lines changed

2 files changed

+11
-143
lines changed
 

‎app/assets/javascripts/joosy/preloaders/caching.js.coffee

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#= require base64
2-
31
#
42
# Preloader for libraries with localStorage cache
53
#
@@ -61,16 +59,21 @@
6159
for name, i in @libraries
6260
flag &&= window.localStorage.getItem(name)?
6361
flag
64-
62+
63+
#
64+
# Escapes non-printable terminal chars before storing to localStorage to prevent IE bug
65+
#
66+
# @param [String] String, that will be prepared for localStorage
67+
#
68+
escapeStr: (str) ->
69+
str.replace(new RegExp("\u0001", 'g'), "\\u0001").replace(new RegExp("\u000B", 'g'), "\\u000B")
70+
6571
#
6672
# Gets sources of scripts from localStorage and evals them
6773
#
6874
restore: ->
6975
for name, i in @libraries
70-
code = window.localStorage.getItem name
71-
if window.navigator.appName == "Microsoft Internet Explorer"
72-
code = Base64.decode code
73-
@evalGlobaly code
76+
@evalGlobaly window.localStorage.getItem name
7477
@complete?.call window, true
7578

7679
#
@@ -90,7 +93,7 @@
9093
@ajax url, size, (xhr) =>
9194
code = xhr.responseText
9295
if window.navigator.appName == "Microsoft Internet Explorer"
93-
code = Base64.encode code
96+
code = @escapeStr code
9497
window.localStorage.setItem @prefix+url, code
9598
@evalGlobaly xhr.responseText
9699
@download libraries

‎vendor/assets/javascripts/base64.js

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.