sidekiq 6.0.3 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sidekiq might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.circleci/config.yml +13 -24
- data/6.0-Upgrade.md +1 -1
- data/Changes.md +61 -0
- data/Ent-Changes.md +15 -2
- data/Gemfile +2 -2
- data/Gemfile.lock +121 -109
- data/Pro-Changes.md +15 -1
- data/README.md +2 -5
- data/bin/sidekiq +26 -2
- data/lib/generators/sidekiq/worker_generator.rb +1 -1
- data/lib/sidekiq.rb +13 -7
- data/lib/sidekiq/api.rb +9 -5
- data/lib/sidekiq/cli.rb +24 -5
- data/lib/sidekiq/client.rb +23 -12
- data/lib/sidekiq/extensions/active_record.rb +3 -2
- data/lib/sidekiq/extensions/class_methods.rb +5 -4
- data/lib/sidekiq/fetch.rb +20 -18
- data/lib/sidekiq/job_logger.rb +1 -1
- data/lib/sidekiq/job_retry.rb +2 -2
- data/lib/sidekiq/launcher.rb +34 -7
- data/lib/sidekiq/logger.rb +9 -9
- data/lib/sidekiq/manager.rb +3 -3
- data/lib/sidekiq/monitor.rb +2 -2
- data/lib/sidekiq/processor.rb +5 -5
- data/lib/sidekiq/rails.rb +16 -18
- data/lib/sidekiq/redis_connection.rb +21 -13
- data/lib/sidekiq/sd_notify.rb +149 -0
- data/lib/sidekiq/systemd.rb +24 -0
- data/lib/sidekiq/testing.rb +1 -1
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web.rb +16 -8
- data/lib/sidekiq/web/application.rb +15 -9
- data/lib/sidekiq/web/csrf_protection.rb +153 -0
- data/lib/sidekiq/web/helpers.rb +4 -7
- data/lib/sidekiq/web/router.rb +2 -4
- data/lib/sidekiq/worker.rb +4 -7
- data/sidekiq.gemspec +2 -3
- data/web/assets/javascripts/application.js +24 -21
- data/web/assets/stylesheets/application-dark.css +132 -124
- data/web/assets/stylesheets/application.css +5 -0
- data/web/locales/en.yml +2 -0
- data/web/locales/fr.yml +2 -2
- data/web/locales/ja.yml +2 -0
- data/web/locales/lt.yml +83 -0
- data/web/locales/pl.yml +4 -4
- data/web/locales/vi.yml +83 -0
- data/web/views/layout.erb +1 -1
- data/web/views/queues.erb +8 -0
- metadata +14 -23
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# Sidekiq's systemd integration allows Sidekiq to inform systemd:
|
3
|
+
# 1. when it has successfully started
|
4
|
+
# 2. when it is starting shutdown
|
5
|
+
# 3. periodically for a liveness check with a watchdog thread
|
6
|
+
#
|
7
|
+
module Sidekiq
|
8
|
+
def self.start_watchdog
|
9
|
+
usec = Integer(ENV["WATCHDOG_USEC"])
|
10
|
+
return Sidekiq.logger.error("systemd Watchdog too fast: " + usec) if usec < 1_000_000
|
11
|
+
|
12
|
+
sec_f = usec / 1_000_000.0
|
13
|
+
# "It is recommended that a daemon sends a keep-alive notification message
|
14
|
+
# to the service manager every half of the time returned here."
|
15
|
+
ping_f = sec_f / 2
|
16
|
+
Sidekiq.logger.info "Pinging systemd watchdog every #{ping_f.round(1)} sec"
|
17
|
+
Thread.new do
|
18
|
+
loop do
|
19
|
+
sleep ping_f
|
20
|
+
Sidekiq::SdNotify.watchdog
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/sidekiq/testing.rb
CHANGED
@@ -337,7 +337,7 @@ module Sidekiq
|
|
337
337
|
Sidekiq::Extensions::DelayedModel.extend(TestingExtensions) if defined?(Sidekiq::Extensions::DelayedModel)
|
338
338
|
end
|
339
339
|
|
340
|
-
if defined?(::Rails) && Rails.respond_to?(:env) && !Rails.env.test?
|
340
|
+
if defined?(::Rails) && Rails.respond_to?(:env) && !Rails.env.test? && !$TESTING
|
341
341
|
puts("**************************************************")
|
342
342
|
puts("⛔️ WARNING: Sidekiq testing API enabled, but this is not the test environment. Your jobs will not go to Redis.")
|
343
343
|
puts("**************************************************")
|
data/lib/sidekiq/version.rb
CHANGED
data/lib/sidekiq/web.rb
CHANGED
@@ -10,8 +10,9 @@ require "sidekiq/web/helpers"
|
|
10
10
|
require "sidekiq/web/router"
|
11
11
|
require "sidekiq/web/action"
|
12
12
|
require "sidekiq/web/application"
|
13
|
+
require "sidekiq/web/csrf_protection"
|
13
14
|
|
14
|
-
require "rack/
|
15
|
+
require "rack/content_length"
|
15
16
|
|
16
17
|
require "rack/builder"
|
17
18
|
require "rack/file"
|
@@ -31,7 +32,7 @@ module Sidekiq
|
|
31
32
|
"Queues" => "queues",
|
32
33
|
"Retries" => "retries",
|
33
34
|
"Scheduled" => "scheduled",
|
34
|
-
"Dead" => "morgue"
|
35
|
+
"Dead" => "morgue"
|
35
36
|
}
|
36
37
|
|
37
38
|
class << self
|
@@ -154,14 +155,14 @@ module Sidekiq
|
|
154
155
|
def build_sessions
|
155
156
|
middlewares = self.middlewares
|
156
157
|
|
157
|
-
unless using?(::Rack::Protection) || ENV["RACK_ENV"] == "test"
|
158
|
-
middlewares.unshift [[::Rack::Protection, {use: :authenticity_token}], nil]
|
159
|
-
end
|
160
|
-
|
161
158
|
s = sessions
|
162
|
-
return unless s
|
163
159
|
|
164
|
-
|
160
|
+
# turn on CSRF protection if sessions are enabled and this is not the test env
|
161
|
+
if s && !using?(CsrfProtection) && ENV["RACK_ENV"] != "test"
|
162
|
+
middlewares.unshift [[CsrfProtection], nil]
|
163
|
+
end
|
164
|
+
|
165
|
+
if s && !using?(::Rack::Session::Cookie)
|
165
166
|
unless (secret = Web.session_secret)
|
166
167
|
require "securerandom"
|
167
168
|
secret = SecureRandom.hex(64)
|
@@ -172,6 +173,13 @@ module Sidekiq
|
|
172
173
|
|
173
174
|
middlewares.unshift [[::Rack::Session::Cookie, options], nil]
|
174
175
|
end
|
176
|
+
|
177
|
+
# Since Sidekiq::WebApplication no longer calculates its own
|
178
|
+
# Content-Length response header, we must ensure that the Rack middleware
|
179
|
+
# that does this is loaded
|
180
|
+
unless using? ::Rack::ContentLength
|
181
|
+
middlewares.unshift [[::Rack::ContentLength], nil]
|
182
|
+
end
|
175
183
|
end
|
176
184
|
|
177
185
|
def build
|
@@ -19,7 +19,7 @@ module Sidekiq
|
|
19
19
|
"script-src 'self' https: http: 'unsafe-inline'",
|
20
20
|
"style-src 'self' https: http: 'unsafe-inline'",
|
21
21
|
"worker-src 'self'",
|
22
|
-
"base-uri 'self'"
|
22
|
+
"base-uri 'self'"
|
23
23
|
].join("; ").freeze
|
24
24
|
|
25
25
|
def initialize(klass)
|
@@ -90,7 +90,15 @@ module Sidekiq
|
|
90
90
|
end
|
91
91
|
|
92
92
|
post "/queues/:name" do
|
93
|
-
Sidekiq::Queue.new(route_params[:name])
|
93
|
+
queue = Sidekiq::Queue.new(route_params[:name])
|
94
|
+
|
95
|
+
if Sidekiq.pro? && params["pause"]
|
96
|
+
queue.pause!
|
97
|
+
elsif Sidekiq.pro? && params["unpause"]
|
98
|
+
queue.unpause!
|
99
|
+
else
|
100
|
+
queue.clear
|
101
|
+
end
|
94
102
|
|
95
103
|
redirect "#{root_path}queues"
|
96
104
|
end
|
@@ -267,7 +275,7 @@ module Sidekiq
|
|
267
275
|
scheduled: sidekiq_stats.scheduled_size,
|
268
276
|
retries: sidekiq_stats.retry_size,
|
269
277
|
dead: sidekiq_stats.dead_size,
|
270
|
-
default_latency: sidekiq_stats.default_queue_latency
|
278
|
+
default_latency: sidekiq_stats.default_queue_latency
|
271
279
|
},
|
272
280
|
redis: redis_stats,
|
273
281
|
server_utc_time: server_utc_time
|
@@ -292,22 +300,20 @@ module Sidekiq
|
|
292
300
|
|
293
301
|
resp = case resp
|
294
302
|
when Array
|
303
|
+
# redirects go here
|
295
304
|
resp
|
296
305
|
else
|
306
|
+
# rendered content goes here
|
297
307
|
headers = {
|
298
308
|
"Content-Type" => "text/html",
|
299
309
|
"Cache-Control" => "no-cache",
|
300
310
|
"Content-Language" => action.locale,
|
301
|
-
"Content-Security-Policy" => CSP_HEADER
|
311
|
+
"Content-Security-Policy" => CSP_HEADER
|
302
312
|
}
|
303
|
-
|
313
|
+
# we'll let Rack calculate Content-Length for us.
|
304
314
|
[200, headers, [resp]]
|
305
315
|
end
|
306
316
|
|
307
|
-
resp[1] = resp[1].dup
|
308
|
-
|
309
|
-
resp[1][CONTENT_LENGTH] = resp[2].sum(&:bytesize).to_s
|
310
|
-
|
311
317
|
resp
|
312
318
|
end
|
313
319
|
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# this file originally based on authenticity_token.rb from the sinatra/rack-protection project
|
4
|
+
#
|
5
|
+
# The MIT License (MIT)
|
6
|
+
#
|
7
|
+
# Copyright (c) 2011-2017 Konstantin Haase
|
8
|
+
# Copyright (c) 2015-2017 Zachary Scott
|
9
|
+
#
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
# a copy of this software and associated documentation files (the
|
12
|
+
# 'Software'), to deal in the Software without restriction, including
|
13
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
# the following conditions:
|
17
|
+
#
|
18
|
+
# The above copyright notice and this permission notice shall be
|
19
|
+
# included in all copies or substantial portions of the Software.
|
20
|
+
#
|
21
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
24
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
25
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
26
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
27
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
|
29
|
+
require "securerandom"
|
30
|
+
require "base64"
|
31
|
+
require "rack/request"
|
32
|
+
|
33
|
+
module Sidekiq
|
34
|
+
class Web
|
35
|
+
class CsrfProtection
|
36
|
+
def initialize(app, options = nil)
|
37
|
+
@app = app
|
38
|
+
end
|
39
|
+
|
40
|
+
def call(env)
|
41
|
+
accept?(env) ? admit(env) : deny(env)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def admit(env)
|
47
|
+
# On each successful request, we create a fresh masked token
|
48
|
+
# which will be used in any forms rendered for this request.
|
49
|
+
s = session(env)
|
50
|
+
s[:csrf] ||= SecureRandom.base64(TOKEN_LENGTH)
|
51
|
+
env[:csrf_token] = mask_token(s[:csrf])
|
52
|
+
@app.call(env)
|
53
|
+
end
|
54
|
+
|
55
|
+
def safe?(env)
|
56
|
+
%w[GET HEAD OPTIONS TRACE].include? env["REQUEST_METHOD"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def logger(env)
|
60
|
+
@logger ||= (env["rack.logger"] || ::Logger.new(env["rack.errors"]))
|
61
|
+
end
|
62
|
+
|
63
|
+
def deny(env)
|
64
|
+
logger(env).warn "attack prevented by #{self.class}"
|
65
|
+
[403, {"Content-Type" => "text/plain"}, ["Forbidden"]]
|
66
|
+
end
|
67
|
+
|
68
|
+
def session(env)
|
69
|
+
env["rack.session"] || fail("you need to set up a session middleware *before* #{self.class}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def accept?(env)
|
73
|
+
return true if safe?(env)
|
74
|
+
|
75
|
+
giventoken = Rack::Request.new(env).params["authenticity_token"]
|
76
|
+
valid_token?(env, giventoken)
|
77
|
+
end
|
78
|
+
|
79
|
+
TOKEN_LENGTH = 32
|
80
|
+
|
81
|
+
# Checks that the token given to us as a parameter matches
|
82
|
+
# the token stored in the session.
|
83
|
+
def valid_token?(env, giventoken)
|
84
|
+
return false if giventoken.nil? || giventoken.empty?
|
85
|
+
|
86
|
+
begin
|
87
|
+
token = decode_token(giventoken)
|
88
|
+
rescue ArgumentError # client input is invalid
|
89
|
+
return false
|
90
|
+
end
|
91
|
+
|
92
|
+
sess = session(env)
|
93
|
+
localtoken = sess[:csrf]
|
94
|
+
|
95
|
+
# Rotate the session token after every use
|
96
|
+
sess[:csrf] = SecureRandom.base64(TOKEN_LENGTH)
|
97
|
+
|
98
|
+
# See if it's actually a masked token or not. We should be able
|
99
|
+
# to handle any unmasked tokens that we've issued without error.
|
100
|
+
|
101
|
+
if unmasked_token?(token)
|
102
|
+
compare_with_real_token token, localtoken
|
103
|
+
elsif masked_token?(token)
|
104
|
+
unmasked = unmask_token(token)
|
105
|
+
compare_with_real_token unmasked, localtoken
|
106
|
+
else
|
107
|
+
false # Token is malformed
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Creates a masked version of the authenticity token that varies
|
112
|
+
# on each request. The masking is used to mitigate SSL attacks
|
113
|
+
# like BREACH.
|
114
|
+
def mask_token(token)
|
115
|
+
token = decode_token(token)
|
116
|
+
one_time_pad = SecureRandom.random_bytes(token.length)
|
117
|
+
encrypted_token = xor_byte_strings(one_time_pad, token)
|
118
|
+
masked_token = one_time_pad + encrypted_token
|
119
|
+
Base64.strict_encode64(masked_token)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Essentially the inverse of +mask_token+.
|
123
|
+
def unmask_token(masked_token)
|
124
|
+
# Split the token into the one-time pad and the encrypted
|
125
|
+
# value and decrypt it
|
126
|
+
token_length = masked_token.length / 2
|
127
|
+
one_time_pad = masked_token[0...token_length]
|
128
|
+
encrypted_token = masked_token[token_length..-1]
|
129
|
+
xor_byte_strings(one_time_pad, encrypted_token)
|
130
|
+
end
|
131
|
+
|
132
|
+
def unmasked_token?(token)
|
133
|
+
token.length == TOKEN_LENGTH
|
134
|
+
end
|
135
|
+
|
136
|
+
def masked_token?(token)
|
137
|
+
token.length == TOKEN_LENGTH * 2
|
138
|
+
end
|
139
|
+
|
140
|
+
def compare_with_real_token(token, local)
|
141
|
+
Rack::Utils.secure_compare(token.to_s, decode_token(local).to_s)
|
142
|
+
end
|
143
|
+
|
144
|
+
def decode_token(token)
|
145
|
+
Base64.strict_decode64(token)
|
146
|
+
end
|
147
|
+
|
148
|
+
def xor_byte_strings(s1, s2)
|
149
|
+
s1.bytes.zip(s2.bytes).map { |(c1, c2)| c1 ^ c2 }.pack("c*")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
data/lib/sidekiq/web/helpers.rb
CHANGED
@@ -201,12 +201,9 @@ module Sidekiq
|
|
201
201
|
|
202
202
|
# Merge options with current params, filter safe params, and stringify to query string
|
203
203
|
def qparams(options)
|
204
|
-
|
205
|
-
options.keys.each do |key|
|
206
|
-
options[key.to_s] = options.delete(key)
|
207
|
-
end
|
204
|
+
stringified_options = options.transform_keys(&:to_s)
|
208
205
|
|
209
|
-
to_query_string(params.merge(
|
206
|
+
to_query_string(params.merge(stringified_options))
|
210
207
|
end
|
211
208
|
|
212
209
|
def to_query_string(params)
|
@@ -233,7 +230,7 @@ module Sidekiq
|
|
233
230
|
end
|
234
231
|
|
235
232
|
def csrf_tag
|
236
|
-
"<input type='hidden' name='authenticity_token' value='#{
|
233
|
+
"<input type='hidden' name='authenticity_token' value='#{env[:csrf_token]}'/>"
|
237
234
|
end
|
238
235
|
|
239
236
|
def to_display(arg)
|
@@ -295,7 +292,7 @@ module Sidekiq
|
|
295
292
|
end
|
296
293
|
|
297
294
|
def environment_title_prefix
|
298
|
-
environment = Sidekiq.options[:environment] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
|
295
|
+
environment = Sidekiq.options[:environment] || ENV["APP_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
|
299
296
|
|
300
297
|
"[#{environment.upcase}] " unless environment == "production"
|
301
298
|
end
|
data/lib/sidekiq/web/router.rb
CHANGED
@@ -66,7 +66,7 @@ module Sidekiq
|
|
66
66
|
class WebRoute
|
67
67
|
attr_accessor :request_method, :pattern, :block, :name
|
68
68
|
|
69
|
-
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([
|
69
|
+
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^.:$\/]+)/
|
70
70
|
|
71
71
|
def initialize(request_method, pattern, block)
|
72
72
|
@request_method = request_method
|
@@ -94,9 +94,7 @@ module Sidekiq
|
|
94
94
|
{} if path == matcher
|
95
95
|
else
|
96
96
|
path_match = path.match(matcher)
|
97
|
-
|
98
|
-
Hash[path_match.names.map(&:to_sym).zip(path_match.captures)]
|
99
|
-
end
|
97
|
+
path_match&.named_captures&.transform_keys(&:to_sym)
|
100
98
|
end
|
101
99
|
end
|
102
100
|
end
|
data/lib/sidekiq/worker.rb
CHANGED
@@ -48,8 +48,8 @@ module Sidekiq
|
|
48
48
|
# In practice, any option is allowed. This is the main mechanism to configure the
|
49
49
|
# options for a specific job.
|
50
50
|
def sidekiq_options(opts = {})
|
51
|
-
opts =
|
52
|
-
self.sidekiq_options_hash = get_sidekiq_options.merge(
|
51
|
+
opts = opts.transform_keys(&:to_s) # stringify
|
52
|
+
self.sidekiq_options_hash = get_sidekiq_options.merge(opts)
|
53
53
|
end
|
54
54
|
|
55
55
|
def sidekiq_retry_in(&block)
|
@@ -235,12 +235,9 @@ module Sidekiq
|
|
235
235
|
|
236
236
|
def client_push(item) # :nodoc:
|
237
237
|
pool = Thread.current[:sidekiq_via_pool] || get_sidekiq_options["pool"] || Sidekiq.redis_pool
|
238
|
-
|
239
|
-
item.keys.each do |key|
|
240
|
-
item[key.to_s] = item.delete(key)
|
241
|
-
end
|
238
|
+
stringified_item = item.transform_keys(&:to_s)
|
242
239
|
|
243
|
-
Sidekiq::Client.new(pool).push(
|
240
|
+
Sidekiq::Client.new(pool).push(stringified_item)
|
244
241
|
end
|
245
242
|
end
|
246
243
|
end
|
data/sidekiq.gemspec
CHANGED
@@ -14,8 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.version = Sidekiq::VERSION
|
15
15
|
gem.required_ruby_version = ">= 2.5.0"
|
16
16
|
|
17
|
-
gem.add_dependency "redis", ">= 4.
|
17
|
+
gem.add_dependency "redis", ">= 4.2.0"
|
18
18
|
gem.add_dependency "connection_pool", ">= 2.2.2"
|
19
|
-
gem.add_dependency "rack", "
|
20
|
-
gem.add_dependency "rack-protection", ">= 2.0.0"
|
19
|
+
gem.add_dependency "rack", "~> 2.0"
|
21
20
|
end
|
@@ -1,5 +1,5 @@
|
|||
1
|
-
/*! jQuery v1.
|
||
2
|
-
(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d
"," "]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1>$2>");try{for(;d |