Index: trunk/extensions/InlineEditor/jquery.json.js |
— | — | @@ -13,7 +13,8 @@ |
14 | 14 | * It is also influenced heavily by MochiKit's serializeJSON, which is |
15 | 15 | * copyrighted 2005 by Bob Ippolito. |
16 | 16 | * |
17 | | - * The script has been modified by Jan Paul Posma to always use $.secureEvalJSON. |
| 17 | + * The script has been modified by Jan Paul Posma by removing $.evalJSON, because jQuery |
| 18 | + * already includes $.parseJSON, and moving variables into functions. |
18 | 19 | */ |
19 | 20 | |
20 | 21 | (function($) { |
— | — | @@ -110,37 +111,7 @@ |
111 | 112 | return "{" + pairs.join(", ") + "}"; |
112 | 113 | } |
113 | 114 | }; |
114 | | - |
115 | | - /** jQuery.evalJSON(src) |
116 | | - Evaluates a given piece of json source. |
117 | | - **/ |
118 | | - $.evalJSON = function(src) |
119 | | - { |
120 | | - return $.secureEvalJSON(src); |
121 | | - //if (typeof(JSON) == 'object' && JSON.parse) |
122 | | - // return JSON.parse(src); |
123 | | - //return eval("(" + src + ")"); |
124 | | - }; |
125 | 115 | |
126 | | - /** jQuery.secureEvalJSON(src) |
127 | | - Evals JSON in a way that is *more* secure. |
128 | | - **/ |
129 | | - $.secureEvalJSON = function(src) |
130 | | - { |
131 | | - if (typeof(JSON) == 'object' && JSON.parse) |
132 | | - return JSON.parse(src); |
133 | | - |
134 | | - var filtered = src; |
135 | | - filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@'); |
136 | | - filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'); |
137 | | - filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, ''); |
138 | | - |
139 | | - if (/^[\],:{}\s]*$/.test(filtered)) |
140 | | - return eval("(" + src + ")"); |
141 | | - else |
142 | | - throw new SyntaxError("Error parsing JSON, source is not valid."); |
143 | | - }; |
144 | | - |
145 | 116 | /** jQuery.quoteString(string) |
146 | 117 | Returns a string-repr of a string, escaping quotes intelligently. |
147 | 118 | Mostly a support function for toJSON. |
— | — | @@ -154,6 +125,18 @@ |
155 | 126 | **/ |
156 | 127 | $.quoteString = function(string) |
157 | 128 | { |
| 129 | + var _escapeable = /["\\\x00-\x1f\x7f-\x9f]/g; |
| 130 | + |
| 131 | + var _meta = { |
| 132 | + '\b': '\\b', |
| 133 | + '\t': '\\t', |
| 134 | + '\n': '\\n', |
| 135 | + '\f': '\\f', |
| 136 | + '\r': '\\r', |
| 137 | + '"' : '\\"', |
| 138 | + '\\': '\\\\' |
| 139 | + }; |
| 140 | + |
158 | 141 | if (string.match(_escapeable)) |
159 | 142 | { |
160 | 143 | return '"' + string.replace(_escapeable, function (a) |
— | — | @@ -166,16 +149,4 @@ |
167 | 150 | } |
168 | 151 | return '"' + string + '"'; |
169 | 152 | }; |
170 | | - |
171 | | - var _escapeable = /["\\\x00-\x1f\x7f-\x9f]/g; |
172 | | - |
173 | | - var _meta = { |
174 | | - '\b': '\\b', |
175 | | - '\t': '\\t', |
176 | | - '\n': '\\n', |
177 | | - '\f': '\\f', |
178 | | - '\r': '\\r', |
179 | | - '"' : '\\"', |
180 | | - '\\': '\\\\' |
181 | | - }; |
182 | 153 | })(jQuery); |