sentry-raven 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sentry-raven might be problematic. Click here for more details.
- data/README.md +2 -0
- data/lib/raven.rb +1 -1
- data/lib/raven/client.rb +2 -8
- data/lib/raven/configuration.rb +1 -2
- data/lib/raven/okjson.rb +607 -0
- data/lib/raven/processors/sanitizedata.rb +11 -5
- data/lib/raven/version.rb +1 -1
- metadata +15 -25
data/README.md
CHANGED
@@ -143,6 +143,8 @@ Raven.configure do |config|
|
|
143
143
|
end
|
144
144
|
```
|
145
145
|
|
146
|
+
You can find the list of exceptions that are excluded by default in [Raven::Configuration::IGNORE_DEFAULT](https://github.com/getsentry/raven-ruby/blob/master/lib/raven/configuration.rb#L74-L80). Remember you'll be overriding those defaults by setting this configuration.
|
147
|
+
|
146
148
|
### Tags
|
147
149
|
|
148
150
|
You can configure default tags to be sent with every event. These can be
|
data/lib/raven.rb
CHANGED
@@ -11,10 +11,10 @@ require 'raven/interfaces/exception'
|
|
11
11
|
require 'raven/interfaces/stack_trace'
|
12
12
|
require 'raven/interfaces/http'
|
13
13
|
require 'raven/processors/sanitizedata'
|
14
|
-
require 'raven/tasks'
|
15
14
|
|
16
15
|
require 'raven/railtie' if defined?(Rails::Railtie)
|
17
16
|
require 'raven/sidekiq' if defined?(Sidekiq)
|
17
|
+
require 'raven/tasks' if defined?(Rake)
|
18
18
|
|
19
19
|
|
20
20
|
module Raven
|
data/lib/raven/client.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'multi_json'
|
2
1
|
require 'zlib'
|
3
2
|
require 'base64'
|
4
3
|
|
5
4
|
require 'raven/version'
|
5
|
+
require 'raven/okjson'
|
6
6
|
require 'raven/transports/http'
|
7
7
|
require 'raven/transports/udp'
|
8
8
|
|
@@ -53,13 +53,7 @@ module Raven
|
|
53
53
|
processor.process(memo)
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
begin
|
58
|
-
old_adapter, MultiJson.adapter = MultiJson.adapter, new_adapter if new_adapter
|
59
|
-
encoded = MultiJson.encode(hash)
|
60
|
-
ensure
|
61
|
-
MultiJson.adapter = old_adapter if new_adapter
|
62
|
-
end
|
56
|
+
encoded = OkJson.encode(hash)
|
63
57
|
|
64
58
|
case self.configuration.encoding
|
65
59
|
when 'gzip'
|
data/lib/raven/configuration.rb
CHANGED
@@ -64,8 +64,7 @@ module Raven
|
|
64
64
|
|
65
65
|
attr_accessor :server_name
|
66
66
|
|
67
|
-
#
|
68
|
-
# intelligent defaults.
|
67
|
+
# DEPRECATED: This option is now ignored as we use our own adapter.
|
69
68
|
attr_accessor :json_adapter
|
70
69
|
|
71
70
|
# Default tags for events
|
data/lib/raven/okjson.rb
ADDED
@@ -0,0 +1,607 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright 2011, 2012 Keith Rarick
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
# See https://github.com/kr/okjson for updates.
|
24
|
+
|
25
|
+
require 'stringio'
|
26
|
+
|
27
|
+
# Some parts adapted from
|
28
|
+
# http://golang.org/src/pkg/json/decode.go and
|
29
|
+
# http://golang.org/src/pkg/utf8/utf8.go
|
30
|
+
module Raven
|
31
|
+
|
32
|
+
module OkJson
|
33
|
+
Upstream = '42'
|
34
|
+
extend self
|
35
|
+
|
36
|
+
|
37
|
+
# Decodes a json document in string s and
|
38
|
+
# returns the corresponding ruby value.
|
39
|
+
# String s must be valid UTF-8. If you have
|
40
|
+
# a string in some other encoding, convert
|
41
|
+
# it first.
|
42
|
+
#
|
43
|
+
# String values in the resulting structure
|
44
|
+
# will be UTF-8.
|
45
|
+
def decode(s)
|
46
|
+
ts = lex(s)
|
47
|
+
v, ts = textparse(ts)
|
48
|
+
if ts.length > 0
|
49
|
+
raise Error, 'trailing garbage'
|
50
|
+
end
|
51
|
+
v
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# Encodes x into a json text. It may contain only
|
56
|
+
# Array, Hash, String, Numeric, true, false, nil.
|
57
|
+
# (Note, this list excludes Symbol.)
|
58
|
+
# X itself must be an Array or a Hash.
|
59
|
+
# No other value can be encoded, and an error will
|
60
|
+
# be raised if x contains any other value, such as
|
61
|
+
# Nan, Infinity, Symbol, and Proc, or if a Hash key
|
62
|
+
# is not a String.
|
63
|
+
# Strings contained in x must be valid UTF-8.
|
64
|
+
def encode(x)
|
65
|
+
visited = []
|
66
|
+
case x
|
67
|
+
when Hash then objenc(x, visited)
|
68
|
+
when Array then arrenc(x, visited)
|
69
|
+
else
|
70
|
+
raise Error, 'root value must be an Array or a Hash'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def valenc(x, visited)
|
76
|
+
case x
|
77
|
+
when Hash then objenc(x, visited)
|
78
|
+
when Array then arrenc(x, visited)
|
79
|
+
when String then strenc(x)
|
80
|
+
when Numeric then numenc(x)
|
81
|
+
when true then "true"
|
82
|
+
when false then "false"
|
83
|
+
when nil then "null"
|
84
|
+
else
|
85
|
+
strenc((x.inspect rescue $!.to_s))
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
|
93
|
+
# Parses a "json text" in the sense of RFC 4627.
|
94
|
+
# Returns the parsed value and any trailing tokens.
|
95
|
+
# Note: this is almost the same as valparse,
|
96
|
+
# except that it does not accept atomic values.
|
97
|
+
def textparse(ts)
|
98
|
+
if ts.length <= 0
|
99
|
+
raise Error, 'empty'
|
100
|
+
end
|
101
|
+
|
102
|
+
typ, _, val = ts[0]
|
103
|
+
case typ
|
104
|
+
when '{' then objparse(ts)
|
105
|
+
when '[' then arrparse(ts)
|
106
|
+
else
|
107
|
+
raise Error, "unexpected #{val.inspect}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
# Parses a "value" in the sense of RFC 4627.
|
113
|
+
# Returns the parsed value and any trailing tokens.
|
114
|
+
def valparse(ts)
|
115
|
+
if ts.length <= 0
|
116
|
+
raise Error, 'empty'
|
117
|
+
end
|
118
|
+
|
119
|
+
typ, _, val = ts[0]
|
120
|
+
case typ
|
121
|
+
when '{' then objparse(ts)
|
122
|
+
when '[' then arrparse(ts)
|
123
|
+
when :val,:str then [val, ts[1..-1]]
|
124
|
+
else
|
125
|
+
raise Error, "unexpected #{val.inspect}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
# Parses an "object" in the sense of RFC 4627.
|
131
|
+
# Returns the parsed value and any trailing tokens.
|
132
|
+
def objparse(ts)
|
133
|
+
ts = eat('{', ts)
|
134
|
+
obj = {}
|
135
|
+
|
136
|
+
if ts[0][0] == '}'
|
137
|
+
return obj, ts[1..-1]
|
138
|
+
end
|
139
|
+
|
140
|
+
k, v, ts = pairparse(ts)
|
141
|
+
obj[k] = v
|
142
|
+
|
143
|
+
if ts[0][0] == '}'
|
144
|
+
return obj, ts[1..-1]
|
145
|
+
end
|
146
|
+
|
147
|
+
loop do
|
148
|
+
ts = eat(',', ts)
|
149
|
+
|
150
|
+
k, v, ts = pairparse(ts)
|
151
|
+
obj[k] = v
|
152
|
+
|
153
|
+
if ts[0][0] == '}'
|
154
|
+
return obj, ts[1..-1]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
# Parses a "member" in the sense of RFC 4627.
|
161
|
+
# Returns the parsed values and any trailing tokens.
|
162
|
+
def pairparse(ts)
|
163
|
+
(typ, _, k), ts = ts[0], ts[1..-1]
|
164
|
+
if typ != :str
|
165
|
+
raise Error, "unexpected #{k.inspect}"
|
166
|
+
end
|
167
|
+
ts = eat(':', ts)
|
168
|
+
v, ts = valparse(ts)
|
169
|
+
[k, v, ts]
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
# Parses an "array" in the sense of RFC 4627.
|
174
|
+
# Returns the parsed value and any trailing tokens.
|
175
|
+
def arrparse(ts)
|
176
|
+
ts = eat('[', ts)
|
177
|
+
arr = []
|
178
|
+
|
179
|
+
if ts[0][0] == ']'
|
180
|
+
return arr, ts[1..-1]
|
181
|
+
end
|
182
|
+
|
183
|
+
v, ts = valparse(ts)
|
184
|
+
arr << v
|
185
|
+
|
186
|
+
if ts[0][0] == ']'
|
187
|
+
return arr, ts[1..-1]
|
188
|
+
end
|
189
|
+
|
190
|
+
loop do
|
191
|
+
ts = eat(',', ts)
|
192
|
+
|
193
|
+
v, ts = valparse(ts)
|
194
|
+
arr << v
|
195
|
+
|
196
|
+
if ts[0][0] == ']'
|
197
|
+
return arr, ts[1..-1]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def eat(typ, ts)
|
204
|
+
if ts[0][0] != typ
|
205
|
+
raise Error, "expected #{typ} (got #{ts[0].inspect})"
|
206
|
+
end
|
207
|
+
ts[1..-1]
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
# Scans s and returns a list of json tokens,
|
212
|
+
# excluding white space (as defined in RFC 4627).
|
213
|
+
def lex(s)
|
214
|
+
ts = []
|
215
|
+
while s.length > 0
|
216
|
+
typ, lexeme, val = tok(s)
|
217
|
+
if typ == nil
|
218
|
+
raise Error, "invalid character at #{s[0,10].inspect}"
|
219
|
+
end
|
220
|
+
if typ != :space
|
221
|
+
ts << [typ, lexeme, val]
|
222
|
+
end
|
223
|
+
s = s[lexeme.length..-1]
|
224
|
+
end
|
225
|
+
ts
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
# Scans the first token in s and
|
230
|
+
# returns a 3-element list, or nil
|
231
|
+
# if s does not begin with a valid token.
|
232
|
+
#
|
233
|
+
# The first list element is one of
|
234
|
+
# '{', '}', ':', ',', '[', ']',
|
235
|
+
# :val, :str, and :space.
|
236
|
+
#
|
237
|
+
# The second element is the lexeme.
|
238
|
+
#
|
239
|
+
# The third element is the value of the
|
240
|
+
# token for :val and :str, otherwise
|
241
|
+
# it is the lexeme.
|
242
|
+
def tok(s)
|
243
|
+
case s[0]
|
244
|
+
when ?{ then ['{', s[0,1], s[0,1]]
|
245
|
+
when ?} then ['}', s[0,1], s[0,1]]
|
246
|
+
when ?: then [':', s[0,1], s[0,1]]
|
247
|
+
when ?, then [',', s[0,1], s[0,1]]
|
248
|
+
when ?[ then ['[', s[0,1], s[0,1]]
|
249
|
+
when ?] then [']', s[0,1], s[0,1]]
|
250
|
+
when ?n then nulltok(s)
|
251
|
+
when ?t then truetok(s)
|
252
|
+
when ?f then falsetok(s)
|
253
|
+
when ?" then strtok(s)
|
254
|
+
when Spc, ?\t, ?\n, ?\r then [:space, s[0,1], s[0,1]]
|
255
|
+
else
|
256
|
+
numtok(s)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
def nulltok(s); s[0,4] == 'null' ? [:val, 'null', nil] : [] end
|
262
|
+
def truetok(s); s[0,4] == 'true' ? [:val, 'true', true] : [] end
|
263
|
+
def falsetok(s); s[0,5] == 'false' ? [:val, 'false', false] : [] end
|
264
|
+
|
265
|
+
|
266
|
+
def numtok(s)
|
267
|
+
m = /-?([1-9][0-9]+|[0-9])([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s)
|
268
|
+
if m && m.begin(0) == 0
|
269
|
+
if !m[2] && !m[3]
|
270
|
+
[:val, m[0], Integer(m[0])]
|
271
|
+
elsif m[2]
|
272
|
+
[:val, m[0], Float(m[0])]
|
273
|
+
else
|
274
|
+
[:val, m[0], Integer(m[1])*(10**Integer(m[3][1..-1]))]
|
275
|
+
end
|
276
|
+
else
|
277
|
+
[]
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
def strtok(s)
|
283
|
+
m = /"([^"\\]|\\["\/\\bfnrt]|\\u[0-9a-fA-F]{4})*"/.match(s)
|
284
|
+
if ! m
|
285
|
+
raise Error, "invalid string literal at #{abbrev(s)}"
|
286
|
+
end
|
287
|
+
[:str, m[0], unquote(m[0])]
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
def abbrev(s)
|
292
|
+
t = s[0,10]
|
293
|
+
p = t['`']
|
294
|
+
t = t[0,p] if p
|
295
|
+
t = t + '...' if t.length < s.length
|
296
|
+
'`' + t + '`'
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
# Converts a quoted json string literal q into a UTF-8-encoded string.
|
301
|
+
# The rules are different than for Ruby, so we cannot use eval.
|
302
|
+
# Unquote will raise an error if q contains control characters.
|
303
|
+
def unquote(q)
|
304
|
+
q = q[1...-1]
|
305
|
+
a = q.dup # allocate a big enough string
|
306
|
+
# In ruby >= 1.9, a[w] is a codepoint, not a byte.
|
307
|
+
if rubydoesenc?
|
308
|
+
a.force_encoding('UTF-8')
|
309
|
+
end
|
310
|
+
r, w = 0, 0
|
311
|
+
while r < q.length
|
312
|
+
c = q[r]
|
313
|
+
if c == ?\\
|
314
|
+
r += 1
|
315
|
+
if r >= q.length
|
316
|
+
raise Error, "string literal ends with a \"\\\": \"#{q}\""
|
317
|
+
end
|
318
|
+
|
319
|
+
case q[r]
|
320
|
+
when ?",?\\,?/,?'
|
321
|
+
a[w] = q[r]
|
322
|
+
r += 1
|
323
|
+
w += 1
|
324
|
+
when ?b,?f,?n,?r,?t
|
325
|
+
a[w] = Unesc[q[r]]
|
326
|
+
r += 1
|
327
|
+
w += 1
|
328
|
+
when ?u
|
329
|
+
r += 1
|
330
|
+
uchar = begin
|
331
|
+
hexdec4(q[r,4])
|
332
|
+
rescue RuntimeError => e
|
333
|
+
raise Error, "invalid escape sequence \\u#{q[r,4]}: #{e}"
|
334
|
+
end
|
335
|
+
r += 4
|
336
|
+
if surrogate? uchar
|
337
|
+
if q.length >= r+6
|
338
|
+
uchar1 = hexdec4(q[r+2,4])
|
339
|
+
uchar = subst(uchar, uchar1)
|
340
|
+
if uchar != Ucharerr
|
341
|
+
# A valid pair; consume.
|
342
|
+
r += 6
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
if rubydoesenc?
|
347
|
+
a[w] = '' << uchar
|
348
|
+
w += 1
|
349
|
+
else
|
350
|
+
w += ucharenc(a, w, uchar)
|
351
|
+
end
|
352
|
+
else
|
353
|
+
raise Error, "invalid escape char #{q[r]} in \"#{q}\""
|
354
|
+
end
|
355
|
+
elsif c == ?" || c < Spc
|
356
|
+
raise Error, "invalid character in string literal \"#{q}\""
|
357
|
+
else
|
358
|
+
# Copy anything else byte-for-byte.
|
359
|
+
# Valid UTF-8 will remain valid UTF-8.
|
360
|
+
# Invalid UTF-8 will remain invalid UTF-8.
|
361
|
+
# In ruby >= 1.9, c is a codepoint, not a byte,
|
362
|
+
# in which case this is still what we want.
|
363
|
+
a[w] = c
|
364
|
+
r += 1
|
365
|
+
w += 1
|
366
|
+
end
|
367
|
+
end
|
368
|
+
a[0,w]
|
369
|
+
end
|
370
|
+
|
371
|
+
|
372
|
+
# Encodes unicode character u as UTF-8
|
373
|
+
# bytes in string a at position i.
|
374
|
+
# Returns the number of bytes written.
|
375
|
+
def ucharenc(a, i, u)
|
376
|
+
if u <= Uchar1max
|
377
|
+
a[i] = (u & 0xff).chr
|
378
|
+
1
|
379
|
+
elsif u <= Uchar2max
|
380
|
+
a[i+0] = (Utag2 | ((u>>6)&0xff)).chr
|
381
|
+
a[i+1] = (Utagx | (u&Umaskx)).chr
|
382
|
+
2
|
383
|
+
elsif u <= Uchar3max
|
384
|
+
a[i+0] = (Utag3 | ((u>>12)&0xff)).chr
|
385
|
+
a[i+1] = (Utagx | ((u>>6)&Umaskx)).chr
|
386
|
+
a[i+2] = (Utagx | (u&Umaskx)).chr
|
387
|
+
3
|
388
|
+
else
|
389
|
+
a[i+0] = (Utag4 | ((u>>18)&0xff)).chr
|
390
|
+
a[i+1] = (Utagx | ((u>>12)&Umaskx)).chr
|
391
|
+
a[i+2] = (Utagx | ((u>>6)&Umaskx)).chr
|
392
|
+
a[i+3] = (Utagx | (u&Umaskx)).chr
|
393
|
+
4
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
|
398
|
+
def hexdec4(s)
|
399
|
+
if s.length != 4
|
400
|
+
raise Error, 'short'
|
401
|
+
end
|
402
|
+
(nibble(s[0])<<12) | (nibble(s[1])<<8) | (nibble(s[2])<<4) | nibble(s[3])
|
403
|
+
end
|
404
|
+
|
405
|
+
|
406
|
+
def subst(u1, u2)
|
407
|
+
if Usurr1 <= u1 && u1 < Usurr2 && Usurr2 <= u2 && u2 < Usurr3
|
408
|
+
return ((u1-Usurr1)<<10) | (u2-Usurr2) + Usurrself
|
409
|
+
end
|
410
|
+
return Ucharerr
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
def surrogate?(u)
|
415
|
+
Usurr1 <= u && u < Usurr3
|
416
|
+
end
|
417
|
+
|
418
|
+
|
419
|
+
def nibble(c)
|
420
|
+
if ?0 <= c && c <= ?9 then c.ord - ?0.ord
|
421
|
+
elsif ?a <= c && c <= ?z then c.ord - ?a.ord + 10
|
422
|
+
elsif ?A <= c && c <= ?Z then c.ord - ?A.ord + 10
|
423
|
+
else
|
424
|
+
raise Error, "invalid hex code #{c}"
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
|
429
|
+
def objenc(x, visited)
|
430
|
+
return '"{...}"' if visited.include?(x.__id__)
|
431
|
+
visited += [x.__id__]
|
432
|
+
'{' + x.map{|k,v| keyenc(k) + ':' + valenc(v, visited)}.join(',') + '}'
|
433
|
+
end
|
434
|
+
|
435
|
+
|
436
|
+
def arrenc(a, visited)
|
437
|
+
return '"[...]"' if visited.include?(a.__id__)
|
438
|
+
visited += [a.__id__]
|
439
|
+
|
440
|
+
'[' + a.map{|x| valenc(x, visited)}.join(',') + ']'
|
441
|
+
end
|
442
|
+
|
443
|
+
|
444
|
+
def keyenc(k)
|
445
|
+
case k
|
446
|
+
when String then strenc(k)
|
447
|
+
else
|
448
|
+
strenc(k.inspect)
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
|
453
|
+
def strenc(s)
|
454
|
+
t = StringIO.new
|
455
|
+
t.putc(?")
|
456
|
+
r = 0
|
457
|
+
|
458
|
+
while r < s.length
|
459
|
+
case s[r]
|
460
|
+
when ?" then t.print('\\"')
|
461
|
+
when ?\\ then t.print('\\\\')
|
462
|
+
when ?\b then t.print('\\b')
|
463
|
+
when ?\f then t.print('\\f')
|
464
|
+
when ?\n then t.print('\\n')
|
465
|
+
when ?\r then t.print('\\r')
|
466
|
+
when ?\t then t.print('\\t')
|
467
|
+
else
|
468
|
+
c = s[r]
|
469
|
+
# In ruby >= 1.9, s[r] is a codepoint, not a byte.
|
470
|
+
if rubydoesenc?
|
471
|
+
begin
|
472
|
+
c.ord # will raise an error if c is invalid UTF-8
|
473
|
+
t.write(c)
|
474
|
+
rescue
|
475
|
+
t.write(Ustrerr)
|
476
|
+
end
|
477
|
+
elsif Spc <= c && c <= ?~
|
478
|
+
t.putc(c)
|
479
|
+
else
|
480
|
+
n = ucharcopy(t, s, r) # ensure valid UTF-8 output
|
481
|
+
r += n - 1 # r is incremented below
|
482
|
+
end
|
483
|
+
end
|
484
|
+
r += 1
|
485
|
+
end
|
486
|
+
t.putc(?")
|
487
|
+
t.string
|
488
|
+
end
|
489
|
+
|
490
|
+
|
491
|
+
def numenc(x)
|
492
|
+
if (x.nan? rescue false)
|
493
|
+
'"NaN"'
|
494
|
+
elsif (x.infinite? rescue false)
|
495
|
+
'"Infinite"'
|
496
|
+
end
|
497
|
+
"#{x}"
|
498
|
+
end
|
499
|
+
|
500
|
+
|
501
|
+
# Copies the valid UTF-8 bytes of a single character
|
502
|
+
# from string s at position i to I/O object t, and
|
503
|
+
# returns the number of bytes copied.
|
504
|
+
# If no valid UTF-8 char exists at position i,
|
505
|
+
# ucharcopy writes Ustrerr and returns 1.
|
506
|
+
def ucharcopy(t, s, i)
|
507
|
+
n = s.length - i
|
508
|
+
raise Utf8Error if n < 1
|
509
|
+
|
510
|
+
c0 = s[i].ord
|
511
|
+
|
512
|
+
# 1-byte, 7-bit sequence?
|
513
|
+
if c0 < Utagx
|
514
|
+
t.putc(c0)
|
515
|
+
return 1
|
516
|
+
end
|
517
|
+
|
518
|
+
raise Utf8Error if c0 < Utag2 # unexpected continuation byte?
|
519
|
+
|
520
|
+
raise Utf8Error if n < 2 # need continuation byte
|
521
|
+
c1 = s[i+1].ord
|
522
|
+
raise Utf8Error if c1 < Utagx || Utag2 <= c1
|
523
|
+
|
524
|
+
# 2-byte, 11-bit sequence?
|
525
|
+
if c0 < Utag3
|
526
|
+
raise Utf8Error if ((c0&Umask2)<<6 | (c1&Umaskx)) <= Uchar1max
|
527
|
+
t.putc(c0)
|
528
|
+
t.putc(c1)
|
529
|
+
return 2
|
530
|
+
end
|
531
|
+
|
532
|
+
# need second continuation byte
|
533
|
+
raise Utf8Error if n < 3
|
534
|
+
|
535
|
+
c2 = s[i+2].ord
|
536
|
+
raise Utf8Error if c2 < Utagx || Utag2 <= c2
|
537
|
+
|
538
|
+
# 3-byte, 16-bit sequence?
|
539
|
+
if c0 < Utag4
|
540
|
+
u = (c0&Umask3)<<12 | (c1&Umaskx)<<6 | (c2&Umaskx)
|
541
|
+
raise Utf8Error if u <= Uchar2max
|
542
|
+
t.putc(c0)
|
543
|
+
t.putc(c1)
|
544
|
+
t.putc(c2)
|
545
|
+
return 3
|
546
|
+
end
|
547
|
+
|
548
|
+
# need third continuation byte
|
549
|
+
raise Utf8Error if n < 4
|
550
|
+
c3 = s[i+3].ord
|
551
|
+
raise Utf8Error if c3 < Utagx || Utag2 <= c3
|
552
|
+
|
553
|
+
# 4-byte, 21-bit sequence?
|
554
|
+
if c0 < Utag5
|
555
|
+
u = (c0&Umask4)<<18 | (c1&Umaskx)<<12 | (c2&Umaskx)<<6 | (c3&Umaskx)
|
556
|
+
raise Utf8Error if u <= Uchar3max
|
557
|
+
t.putc(c0)
|
558
|
+
t.putc(c1)
|
559
|
+
t.putc(c2)
|
560
|
+
t.putc(c3)
|
561
|
+
return 4
|
562
|
+
end
|
563
|
+
|
564
|
+
raise Utf8Error
|
565
|
+
rescue Utf8Error
|
566
|
+
t.write(Ustrerr)
|
567
|
+
return 1
|
568
|
+
end
|
569
|
+
|
570
|
+
|
571
|
+
def rubydoesenc?
|
572
|
+
::String.method_defined?(:force_encoding)
|
573
|
+
end
|
574
|
+
|
575
|
+
|
576
|
+
class Utf8Error < ::StandardError
|
577
|
+
end
|
578
|
+
|
579
|
+
|
580
|
+
class Error < ::StandardError
|
581
|
+
end
|
582
|
+
|
583
|
+
|
584
|
+
Utagx = 0b1000_0000
|
585
|
+
Utag2 = 0b1100_0000
|
586
|
+
Utag3 = 0b1110_0000
|
587
|
+
Utag4 = 0b1111_0000
|
588
|
+
Utag5 = 0b1111_1000
|
589
|
+
Umaskx = 0b0011_1111
|
590
|
+
Umask2 = 0b0001_1111
|
591
|
+
Umask3 = 0b0000_1111
|
592
|
+
Umask4 = 0b0000_0111
|
593
|
+
Uchar1max = (1<<7) - 1
|
594
|
+
Uchar2max = (1<<11) - 1
|
595
|
+
Uchar3max = (1<<16) - 1
|
596
|
+
Ucharerr = 0xFFFD # unicode "replacement char"
|
597
|
+
Ustrerr = "\xef\xbf\xbd" # unicode "replacement char"
|
598
|
+
Usurrself = 0x10000
|
599
|
+
Usurr1 = 0xd800
|
600
|
+
Usurr2 = 0xdc00
|
601
|
+
Usurr3 = 0xe000
|
602
|
+
|
603
|
+
Spc = ' '[0]
|
604
|
+
Unesc = {?b=>?\b, ?f=>?\f, ?n=>?\n, ?r=>?\r, ?t=>?\t}
|
605
|
+
end
|
606
|
+
|
607
|
+
end
|
@@ -8,15 +8,21 @@ module Raven
|
|
8
8
|
FIELDS_RE = /(authorization|password|passwd|secret)/i
|
9
9
|
VALUES_RE = /^\d{16}$/
|
10
10
|
|
11
|
-
def apply(value, key=nil, &block)
|
11
|
+
def apply(value, key=nil, visited=[], &block)
|
12
12
|
if value.is_a?(Hash)
|
13
|
+
return "{...}" if visited.include?(value.__id__)
|
14
|
+
visited += [value.__id__]
|
15
|
+
|
13
16
|
value.each.inject({}) do |memo, (k, v)|
|
14
|
-
memo[k] = apply(v, k, &block)
|
17
|
+
memo[k] = apply(v, k, visited, &block)
|
15
18
|
memo
|
16
19
|
end
|
17
20
|
elsif value.is_a?(Array)
|
18
|
-
|
19
|
-
|
21
|
+
return "[...]" if visited.include?(value.__id__)
|
22
|
+
visited += [value.__id__]
|
23
|
+
|
24
|
+
value.map do |value_|
|
25
|
+
apply(value_, key, visited, &block)
|
20
26
|
end
|
21
27
|
else
|
22
28
|
block.call(key, value)
|
@@ -40,4 +46,4 @@ module Raven
|
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
43
|
-
end
|
49
|
+
end
|
data/lib/raven/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-raven
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-07-
|
13
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
17
|
-
requirement: &
|
17
|
+
requirement: &70349832595800 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.7.6
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70349832595800
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: uuidtools
|
28
|
-
requirement: &
|
28
|
+
requirement: &70349832595340 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,21 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: multi_json
|
39
|
-
requirement: &70301602281340 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '1.0'
|
45
|
-
type: :runtime
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *70301602281340
|
36
|
+
version_requirements: *70349832595340
|
48
37
|
- !ruby/object:Gem::Dependency
|
49
38
|
name: hashie
|
50
|
-
requirement: &
|
39
|
+
requirement: &70349832594800 !ruby/object:Gem::Requirement
|
51
40
|
none: false
|
52
41
|
requirements:
|
53
42
|
- - ! '>='
|
@@ -55,10 +44,10 @@ dependencies:
|
|
55
44
|
version: 1.1.0
|
56
45
|
type: :runtime
|
57
46
|
prerelease: false
|
58
|
-
version_requirements: *
|
47
|
+
version_requirements: *70349832594800
|
59
48
|
- !ruby/object:Gem::Dependency
|
60
49
|
name: rake
|
61
|
-
requirement: &
|
50
|
+
requirement: &70349832594280 !ruby/object:Gem::Requirement
|
62
51
|
none: false
|
63
52
|
requirements:
|
64
53
|
- - ! '>='
|
@@ -66,10 +55,10 @@ dependencies:
|
|
66
55
|
version: '0'
|
67
56
|
type: :development
|
68
57
|
prerelease: false
|
69
|
-
version_requirements: *
|
58
|
+
version_requirements: *70349832594280
|
70
59
|
- !ruby/object:Gem::Dependency
|
71
60
|
name: rspec
|
72
|
-
requirement: &
|
61
|
+
requirement: &70349832592760 !ruby/object:Gem::Requirement
|
73
62
|
none: false
|
74
63
|
requirements:
|
75
64
|
- - ~>
|
@@ -77,10 +66,10 @@ dependencies:
|
|
77
66
|
version: '2.10'
|
78
67
|
type: :development
|
79
68
|
prerelease: false
|
80
|
-
version_requirements: *
|
69
|
+
version_requirements: *70349832592760
|
81
70
|
- !ruby/object:Gem::Dependency
|
82
71
|
name: coveralls
|
83
|
-
requirement: &
|
72
|
+
requirement: &70349832591980 !ruby/object:Gem::Requirement
|
84
73
|
none: false
|
85
74
|
requirements:
|
86
75
|
- - ! '>='
|
@@ -88,7 +77,7 @@ dependencies:
|
|
88
77
|
version: '0'
|
89
78
|
type: :development
|
90
79
|
prerelease: false
|
91
|
-
version_requirements: *
|
80
|
+
version_requirements: *70349832591980
|
92
81
|
description:
|
93
82
|
email: noah@coderanger.net
|
94
83
|
executables:
|
@@ -112,6 +101,7 @@ files:
|
|
112
101
|
- lib/raven/interfaces.rb
|
113
102
|
- lib/raven/linecache.rb
|
114
103
|
- lib/raven/logger.rb
|
104
|
+
- lib/raven/okjson.rb
|
115
105
|
- lib/raven/processor.rb
|
116
106
|
- lib/raven/processors/sanitizedata.rb
|
117
107
|
- lib/raven/rack.rb
|