OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 // Return on blank payloads or on payloads significantly smaller than origin
al text. | 146 // Return on blank payloads or on payloads significantly smaller than origin
al text. |
147 if (inner.length === -1 || text.length - inner.length > 80) | 147 if (inner.length === -1 || text.length - inner.length > 80) |
148 return null; | 148 return null; |
149 | 149 |
150 var prefix = text.substring(0, inner.start); | 150 var prefix = text.substring(0, inner.start); |
151 var suffix = text.substring(inner.end + 1); | 151 var suffix = text.substring(inner.end + 1); |
152 text = text.substring(inner.start, inner.end + 1); | 152 text = text.substring(inner.start, inner.end + 1); |
153 | 153 |
154 // Only process valid JSONP. | 154 // Only process valid JSONP. |
155 if (suffix.length && !(suffix.trim().startsWith(")") && prefix.trim().endsWi
th("("))) | 155 if (suffix.trim().length && !(suffix.trim().startsWith(")") && prefix.trim()
.endsWith("("))) |
156 return null; | 156 return null; |
157 | 157 |
158 try { | 158 try { |
159 return new WebInspector.ParsedJSON(WebInspector.RequestJSONView._buildOb
jectFromJSON(text), prefix, suffix); | 159 return new WebInspector.ParsedJSON(WebInspector.RequestJSONView._buildOb
jectFromJSON(text), prefix, suffix); |
160 } catch (e) { | 160 } catch (e) { |
161 return null; | 161 return null; |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 /** | 165 /** |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 /** | 204 /** |
205 * @constructor | 205 * @constructor |
206 */ | 206 */ |
207 WebInspector.ParsedJSON = function(data, prefix, suffix) | 207 WebInspector.ParsedJSON = function(data, prefix, suffix) |
208 { | 208 { |
209 this.data = data; | 209 this.data = data; |
210 this.prefix = prefix; | 210 this.prefix = prefix; |
211 this.suffix = suffix; | 211 this.suffix = suffix; |
212 } | 212 } |
OLD | NEW |