sidekiq 6.0.7 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sidekiq might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/.circleci/config.yml +13 -2
 - data/Changes.md +18 -0
 - data/Ent-Changes.md +14 -1
 - data/Gemfile +1 -1
 - data/Gemfile.lock +91 -91
 - data/Pro-Changes.md +11 -3
 - data/README.md +2 -5
 - data/bin/sidekiq +7 -2
 - data/lib/sidekiq.rb +4 -2
 - data/lib/sidekiq/api.rb +1 -1
 - data/lib/sidekiq/cli.rb +10 -2
 - data/lib/sidekiq/client.rb +15 -10
 - 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/launcher.rb +3 -2
 - data/lib/sidekiq/manager.rb +3 -3
 - data/lib/sidekiq/processor.rb +4 -4
 - data/lib/sidekiq/rails.rb +16 -18
 - data/lib/sidekiq/redis_connection.rb +15 -12
 - data/lib/sidekiq/sd_notify.rb +1 -1
 - data/lib/sidekiq/testing.rb +1 -1
 - data/lib/sidekiq/version.rb +1 -1
 - data/lib/sidekiq/web.rb +15 -7
 - data/lib/sidekiq/web/csrf_protection.rb +153 -0
 - data/lib/sidekiq/web/helpers.rb +3 -6
 - data/lib/sidekiq/web/router.rb +1 -1
 - data/lib/sidekiq/worker.rb +2 -5
 - data/sidekiq.gemspec +1 -2
 - data/web/assets/javascripts/application.js +2 -2
 - data/web/assets/stylesheets/application-dark.css +15 -4
 - data/web/assets/stylesheets/application.css +5 -0
 - data/web/locales/pl.yml +4 -4
 - metadata +6 -19
 
| 
         @@ -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)
         
     | 
    
        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
         
     | 
    
        data/lib/sidekiq/worker.rb
    CHANGED
    
    | 
         @@ -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 
19 
     | 
    
         
             
              gem.add_dependency "rack", "~> 2.0"
         
     | 
| 
       20 
     | 
    
         
            -
              gem.add_dependency "rack-protection", ">= 2.0.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 |