Thorsten Eckel 2019-09-16 11:21:10 +02:00
parent 429b95e65d
commit 1c63e96675
36 changed files with 51 additions and 51 deletions

View file

@ -448,8 +448,8 @@ GEM
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7) unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.1.0) rubocop-performance (1.4.1)
rubocop (>= 0.67.0) rubocop (>= 0.71.0)
rubocop-rails (2.3.2) rubocop-rails (2.3.2)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 0.72.0) rubocop (>= 0.72.0)

View file

@ -303,7 +303,7 @@ curl http://localhost/api/v1/monitoring/amount_check?token=XXX&periode=1h
raise Exceptions::UnprocessableEntity, 'periode is missing!' if params[:periode].blank? raise Exceptions::UnprocessableEntity, 'periode is missing!' if params[:periode].blank?
scale = params[:periode][-1, 1] scale = params[:periode][-1, 1]
raise Exceptions::UnprocessableEntity, 'periode need to have s, m, h or d as last!' if scale !~ /^(s|m|h|d)$/ raise Exceptions::UnprocessableEntity, 'periode need to have s, m, h or d as last!' if !scale.match?(/^(s|m|h|d)$/)
periode = params[:periode][0, params[:periode].length - 1] periode = params[:periode][0, params[:periode].length - 1]
raise Exceptions::UnprocessableEntity, 'periode need to be an integer!' if periode.to_i.zero? raise Exceptions::UnprocessableEntity, 'periode need to be an integer!' if periode.to_i.zero?

View file

@ -182,7 +182,7 @@ example
# check if verify message exists # check if verify message exists
subject = message_meta['ENVELOPE'].subject subject = message_meta['ENVELOPE'].subject
next if !subject next if !subject
next if subject !~ /#{verify_string}/ next if !subject.match?(/#{verify_string}/)
Rails.logger.info " - verify email #{verify_string} found" Rails.logger.info " - verify email #{verify_string} found"
timeout(600) do timeout(600) do

View file

@ -117,7 +117,7 @@ returns
next if !mail next if !mail
# check if verify message exists # check if verify message exists
next if mail !~ /#{verify_string}/ next if !mail.match?(/#{verify_string}/)
Rails.logger.info " - verify email #{verify_string} found" Rails.logger.info " - verify email #{verify_string} found"
m.delete m.delete

View file

@ -734,7 +734,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
'image/gif': %w[gif image], 'image/gif': %w[gif image],
} }
map.each do |type, ext| map.each do |type, ext|
next if headers_store['Content-Type'] !~ /^#{Regexp.quote(type)}/i next if !headers_store['Content-Type'].match?(/^#{Regexp.quote(type)}/i)
filename = if headers_store['Content-Description'].present? filename = if headers_store['Content-Description'].present?
"#{headers_store['Content-Description']}.#{ext[0]}".to_s.force_encoding('utf-8') "#{headers_store['Content-Description']}.#{ext[0]}".to_s.force_encoding('utf-8')

View file

@ -8,7 +8,7 @@ module Channel::Filter::FollowUpPossibleCheck
ticket = Ticket.lookup(id: ticket_id) ticket = Ticket.lookup(id: ticket_id)
return true if !ticket return true if !ticket
return true if ticket.state.state_type.name !~ /^(closed|merged|removed)/i return true if !ticket.state.state_type.name.match?(/^(closed|merged|removed)/i)
# in case of closed tickets, remove follow-up information # in case of closed tickets, remove follow-up information
case ticket.group.follow_up_possible case ticket.group.follow_up_possible

View file

@ -104,7 +104,7 @@ module Channel::Filter::IdentifySender
items.each do |address_data| items.each do |address_data|
email_address = address_data.address email_address = address_data.address
next if email_address.blank? next if email_address.blank?
next if email_address !~ /@/ next if !email_address.match?(/@/)
next if email_address.match?(/\s/) next if email_address.match?(/\s/)
user_create( user_create(
@ -132,7 +132,7 @@ module Channel::Filter::IdentifySender
display_name = $1 display_name = $1
end end
next if address.blank? next if address.blank?
next if address !~ /@/ next if !address.match?(/@/)
next if address.match?(/\s/) next if address.match?(/\s/)
user_create( user_create(

View file

@ -8,7 +8,7 @@ module Channel::Filter::OutOfOfficeCheck
# check ms out of office characteristics # check ms out of office characteristics
if mail[ 'x-auto-response-suppress'.to_sym ] if mail[ 'x-auto-response-suppress'.to_sym ]
return if mail[ 'x-auto-response-suppress'.to_sym ] !~ /all/i return if !mail[ 'x-auto-response-suppress'.to_sym ].match?(/all/i)
return if !mail[ 'x-ms-exchange-inbox-rules-loop'.to_sym ] return if !mail[ 'x-ms-exchange-inbox-rules-loop'.to_sym ]
mail[ 'x-zammad-out-of-office'.to_sym ] = true mail[ 'x-zammad-out-of-office'.to_sym ] = true

View file

@ -9,10 +9,10 @@ module Channel::Filter::OwnNotificationLoopDetection
recedence = mail['precedence'.to_sym] recedence = mail['precedence'.to_sym]
return if !recedence return if !recedence
return if recedence !~ /bulk/i return if !recedence.match?(/bulk/i)
fqdn = Setting.get('fqdn') fqdn = Setting.get('fqdn')
return if message_id !~ /@#{Regexp.quote(fqdn)}>/i return if !message_id.match?(/@#{Regexp.quote(fqdn)}>/i)
mail[ 'x-zammad-ignore'.to_sym ] = true mail[ 'x-zammad-ignore'.to_sym ] = true
Rails.logger.info "Detected own sent notification mail and dropped it to prevent loops (message_id: #{message_id}, from: #{mail[:from]}, to: #{mail[:to]})" Rails.logger.info "Detected own sent notification mail and dropped it to prevent loops (message_id: #{message_id}, from: #{mail[:from]}, to: #{mail[:to]})"

View file

@ -8,7 +8,7 @@ module Channel::Filter::Trusted
# check if trust x-headers # check if trust x-headers
if !channel[:trusted] if !channel[:trusted]
mail.each_key do |key| mail.each_key do |key|
next if key !~ /^x-zammad/i next if !key.match?(/^x-zammad/i)
mail.delete(key) mail.delete(key)
end end
@ -17,7 +17,7 @@ module Channel::Filter::Trusted
# verify values # verify values
mail.each do |key, value| mail.each do |key, value|
next if key !~ /^x-zammad/i next if !key.match?(/^x-zammad/i)
# no assoc exists, remove header # no assoc exists, remove header
next if Channel::EmailParser.check_attributes_by_x_headers(key, value) next if Channel::EmailParser.check_attributes_by_x_headers(key, value)

View file

@ -75,7 +75,7 @@ returns
# check order # check order
params[:order_by].each do |value| params[:order_by].each do |value|
raise "Found invalid order by value #{value}. Please use 'asc' or 'desc'." if value !~ /\A(asc|desc)\z/i raise "Found invalid order by value #{value}. Please use 'asc' or 'desc'." if !value.match?(/\A(asc|desc)\z/i)
order_by.push(value.downcase) order_by.push(value.downcase)
end end

View file

@ -94,7 +94,7 @@ class Cti::Driver::Base
if routing_table.present? if routing_table.present?
routing_table.each do |row| routing_table.each do |row|
dest = row[:dest].gsub(/\*/, '.+?') dest = row[:dest].gsub(/\*/, '.+?')
next if to !~ /^#{dest}$/ next if !to.match?(/^#{dest}$/)
return { return {
action: 'set_caller_id', action: 'set_caller_id',

View file

@ -48,7 +48,7 @@ check and if channel not exists reset configured channels for email addresses
return true if email.blank? return true if email.blank?
self.email = email.downcase.strip self.email = email.downcase.strip
raise Exceptions::UnprocessableEntity, 'Invalid email' if email !~ /@/ raise Exceptions::UnprocessableEntity, 'Invalid email' if !email.match?(/@/)
raise Exceptions::UnprocessableEntity, 'Invalid email' if email.match?(/\s/) raise Exceptions::UnprocessableEntity, 'Invalid email' if email.match?(/\s/)
true true

View file

@ -23,7 +23,7 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
type = Ticket::Article::Type.lookup(id: record.type_id) type = Ticket::Article::Type.lookup(id: record.type_id)
return true if type.nil? return true if type.nil?
return true if type.name !~ /\Afacebook/ return true if !type.name.start_with?('facebook')
Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateFacebook::BackgroundJob.new(record.id)) Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateFacebook::BackgroundJob.new(record.id))
end end

View file

@ -14,7 +14,7 @@ class Observer::Ticket::Article::CommunicateFacebook::BackgroundJob
log_error(article, "Can't find ticket.preferences for Ticket.find(#{article.ticket_id})") if !ticket.preferences log_error(article, "Can't find ticket.preferences for Ticket.find(#{article.ticket_id})") if !ticket.preferences
log_error(article, "Can't find ticket.preferences['channel_id'] for Ticket.find(#{article.ticket_id})") if !ticket.preferences['channel_id'] log_error(article, "Can't find ticket.preferences['channel_id'] for Ticket.find(#{article.ticket_id})") if !ticket.preferences['channel_id']
channel = Channel.lookup(id: ticket.preferences['channel_id']) channel = Channel.lookup(id: ticket.preferences['channel_id'])
log_error(article, "Channel.find(#{channel.id}) isn't a twitter channel!") if channel.options[:adapter] !~ /\Afacebook/i log_error(article, "Channel.find(#{channel.id}) isn't a twitter channel!") if !channel.options[:adapter].match?(/\Afacebook/i)
# check source object id # check source object id
if !ticket.preferences['channel_fb_object_id'] if !ticket.preferences['channel_fb_object_id']

View file

@ -19,7 +19,7 @@ class Observer::Ticket::Article::CommunicateTelegram < ActiveRecord::Observer
return true if !record.type_id return true if !record.type_id
type = Ticket::Article::Type.lookup(id: record.type_id) type = Ticket::Article::Type.lookup(id: record.type_id)
return true if type.name !~ /\Atelegram/i return true if !type.name.match?(/\Atelegram/i)
Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateTelegram::BackgroundJob.new(record.id)) Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateTelegram::BackgroundJob.new(record.id))
end end

View file

@ -24,7 +24,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
type = Ticket::Article::Type.lookup(id: record.type_id) type = Ticket::Article::Type.lookup(id: record.type_id)
return true if type.nil? return true if type.nil?
return true if type.name !~ /\Atwitter/i return true if !type.name.match?(/\Atwitter/i)
raise Exceptions::UnprocessableEntity, 'twitter to: parameter is missing' if record.to.blank? && type['name'] == 'twitter direct-message' raise Exceptions::UnprocessableEntity, 'twitter to: parameter is missing' if record.to.blank? && type['name'] == 'twitter direct-message'

View file

@ -30,7 +30,7 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
end end
log_error(article, "No such channel id #{ticket.preferences['channel_id']}") if !channel log_error(article, "No such channel id #{ticket.preferences['channel_id']}") if !channel
log_error(article, "Channel.find(#{channel.id}) isn't a twitter channel!") if channel.options[:adapter] !~ /\Atwitter/i log_error(article, "Channel.find(#{channel.id}) isn't a twitter channel!") if !channel.options[:adapter].match?(/\Atwitter/i)
begin begin
tweet = channel.deliver( tweet = channel.deliver(

View file

@ -523,7 +523,7 @@ execute all pending package migrations at once
end end
migrations_existing.each do |migration| migrations_existing.each do |migration|
next if migration !~ /\.rb$/ next if !migration.match?(/\.rb$/)
version = nil version = nil
name = nil name = nil

View file

@ -568,7 +568,7 @@ condition example
selector = selector_raw.stringify_keys selector = selector_raw.stringify_keys
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator'] raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
raise "Invalid selector, operator #{selector['operator']} is invalid #{selector.inspect}" if selector['operator'] !~ /^(is|is\snot|contains|contains\s(not|all|one|all\snot|one\snot)|(after|before)\s\(absolute\)|(within\snext|within\slast|after|before)\s\(relative\))$/ raise "Invalid selector, operator #{selector['operator']} is invalid #{selector.inspect}" if !selector['operator'].match?(/^(is|is\snot|contains|contains\s(not|all|one|all\snot|one\snot)|(after|before)\s\(absolute\)|(within\snext|within\slast|after|before)\s\(relative\))$/)
# validate value / allow blank but only if pre_condition exists and is not specific # validate value / allow blank but only if pre_condition exists and is not specific
if !selector.key?('value') || if !selector.key?('value') ||
@ -1358,7 +1358,7 @@ result
# send notifications only to email addresses # send notifications only to email addresses
next if recipient_email.blank? next if recipient_email.blank?
next if recipient_email !~ /@/ next if !recipient_email.match?(/@/)
# check if address is valid # check if address is valid
begin begin
@ -1375,7 +1375,7 @@ result
recipient_email = "#{$2}@#{$3}" recipient_email = "#{$2}@#{$3}"
end end
next if recipient_email.blank? next if recipient_email.blank?
next if recipient_email !~ /@/ next if !recipient_email.match?(/@/)
next if recipient_email.match?(/\s/) next if recipient_email.match?(/\s/)
end end

View file

@ -69,7 +69,7 @@ returns
def self.insert_urls(article) def self.insert_urls(article)
return article if article['attachments'].blank? return article if article['attachments'].blank?
return article if article['content_type'] !~ %r{text/html}i return article if !article['content_type'].match?(%r{text/html}i)
return article if article['body'] !~ /<img/i return article if article['body'] !~ /<img/i
inline_attachments = {} inline_attachments = {}

View file

@ -114,8 +114,8 @@ class Transaction::Notification
already_notified = false already_notified = false
History.list('Ticket', ticket.id).each do |history| History.list('Ticket', ticket.id).each do |history|
next if history['type'] != 'notification' next if history['type'] != 'notification'
next if history['value_to'] !~ /\(#{Regexp.escape(@item[:type])}:/ next if !history['value_to'].match?(/\(#{Regexp.escape(@item[:type])}:/)
next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/ next if !history['value_to'].match?(/#{Regexp.escape(identifier)}\(/)
next if !history['created_at'].today? next if !history['created_at'].today?
already_notified = true already_notified = true

View file

@ -415,7 +415,7 @@ Get source file at https://i18n.zammad.com/api/v1/translations_empty_translation
next next
end end
raise "Can't import translation, format is missing" if row[2].blank? raise "Can't import translation, format is missing" if row[2].blank?
raise "Can't import translation, format is invalid (#{row[2]})" if row[2] !~ /^(time|string)$/ raise "Can't import translation, format is invalid (#{row[2]})" if !row[2].match?(/^(time|string)$/)
item = { item = {
'locale' => locale.locale, 'locale' => locale.locale,

View file

@ -959,7 +959,7 @@ try to find correct name
self.email = email.downcase.strip self.email = email.downcase.strip
return true if id == 1 return true if id == 1
raise Exceptions::UnprocessableEntity, 'Invalid email' if email !~ /@/ raise Exceptions::UnprocessableEntity, 'Invalid email' if !email.match?(/@/)
raise Exceptions::UnprocessableEntity, 'Invalid email' if email.match?(/\s/) raise Exceptions::UnprocessableEntity, 'Invalid email' if email.match?(/\s/)
true true
@ -1182,7 +1182,7 @@ raise 'Minimum one user need to have admin permissions'
def avatar_for_email_check def avatar_for_email_check
return true if Setting.get('import_mode') return true if Setting.get('import_mode')
return true if email.blank? return true if email.blank?
return true if email !~ /@/ return true if !email.match?(/@/)
return true if !saved_change_to_attribute?('email') && updated_at > Time.zone.now - 10.days return true if !saved_change_to_attribute?('email') && updated_at > Time.zone.now - 10.days
# save/update avatar # save/update avatar

View file

@ -71,7 +71,7 @@ returns on fail
provider_map.each_value do |settings| provider_map.each_value do |settings|
domains.each do |domain_to_check| domains.each do |domain_to_check|
next if domain_to_check !~ /#{settings[:domain]}/i next if !domain_to_check.match?(/#{settings[:domain]}/i)
# add folder to config if needed # add folder to config if needed
if params[:folder].present? && settings[:inbound] && settings[:inbound][:options] if params[:folder].present? && settings[:inbound] && settings[:inbound][:options]
@ -339,7 +339,7 @@ returns on fail
} }
white_map.each_key do |key| white_map.each_key do |key|
next if e.message !~ /#{Regexp.escape(key)}/i next if !e.message.match?(/#{Regexp.escape(key)}/i)
return { return {
result: 'ok', result: 'ok',

View file

@ -168,7 +168,7 @@ satinize html string based on whiltelist
next if !node[attribute_name] next if !node[attribute_name]
href = cleanup_target(node[attribute_name]) href = cleanup_target(node[attribute_name])
next if href !~ /(javascript|livescript|vbscript):/i next if !href.match?(/(javascript|livescript|vbscript):/i)
node.delete(attribute_name) node.delete(attribute_name)
end end

View file

@ -141,7 +141,7 @@ or with filter:
def self._url_cleanup(url) def self._url_cleanup(url)
url.strip! url.strip!
raise "Invalid endpoint '#{url}', need to start with http:// or https://" if url !~ %r{^http(s|)://}i raise "Invalid endpoint '#{url}', need to start with http:// or https://" if !url.match?(%r{^http(s|)://}i)
url = _url_cleanup_baseurl(url) url = _url_cleanup_baseurl(url)
url = "#{url}/src/jsonrpc.php" url = "#{url}/src/jsonrpc.php"
@ -150,7 +150,7 @@ or with filter:
def self._url_cleanup_baseurl(url) def self._url_cleanup_baseurl(url)
url.strip! url.strip!
raise "Invalid endpoint '#{url}', need to start with http:// or https://" if url !~ %r{^http(s|)://}i raise "Invalid endpoint '#{url}', need to start with http:// or https://" if !url.match?(%r{^http(s|)://}i)
url.gsub!(%r{src/jsonrpc.php}, '') url.gsub!(%r{src/jsonrpc.php}, '')
url.gsub(%r{([^:])//+}, '\\1/') url.gsub(%r{([^:])//+}, '\\1/')

View file

@ -160,7 +160,7 @@ module Import
result.push 'Admin' result.push 'Admin'
end end
return result if group['Name'] !~ /^(stats|report)/ return result if !group['Name'].match?(/^(stats|report)/)
return result if !( permissions.include?('ro') || permissions.include?('rw') ) return result if !( permissions.include?('ro') || permissions.include?('rw') )
result.push 'Report' result.push 'Report'

View file

@ -221,8 +221,8 @@ retunes
result.each do |item| result.each do |item|
next if item['type'] != 'notification' next if item['type'] != 'notification'
next if item['object'] != 'Ticket' next if item['object'] != 'Ticket'
next if item['value_to'] !~ /#{recipient.email}/i next if !item['value_to'].match?(/#{recipient.email}/i)
next if item['value_to'] !~ /#{type}/i next if !item['value_to'].match?(/#{type}/i)
count += 1 count += 1
end end

View file

@ -20,7 +20,7 @@ class Sequencer
break if extractor.enough break if extractor.enough
end end
rescue NoMethodError => e rescue NoMethodError => e
raise if e.message !~ /Viewpoint::EWS::/ raise if !e.message.match?(/Viewpoint::EWS::/)
logger.error e logger.error e
logger.error "Skipping folder_id '#{folder_id}' due to unsupported entries." logger.error "Skipping folder_id '#{folder_id}' due to unsupported entries."

View file

@ -440,7 +440,7 @@ returns
files.push entry files.push entry
end end
files.sort.each do |entry| files.sort.each do |entry|
next if entry !~ /^send/ next if !entry.match?(/^send/)
message = Sessions.queue_file_read(path, entry) message = Sessions.queue_file_read(path, entry)
next if !message next if !message

View file

@ -86,7 +86,7 @@ class Stats::TicketChannelDistribution
} }
type_ids = [] type_ids = []
Ticket::Article::Type.all.each do |type| Ticket::Article::Type.all.each do |type|
next if type.name !~ /^#{channel[:sender]}/i next if !type.name.match?(/^#{channel[:sender]}/i)
type_ids.push type.id type_ids.push type.id
end end

View file

@ -289,8 +289,8 @@ end
def es_pipeline? def es_pipeline?
number = es_version number = es_version
return false if number.blank? return false if number.blank?
return false if number =~ /^[2-4]\./ return false if number.match?(/^[2-4]\./)
return false if number =~ /^5\.[0-5]\./ return false if number.match?(/^5\.[0-5]\./)
true true
end end
@ -299,7 +299,7 @@ end
def es_multi_index? def es_multi_index?
number = es_version number = es_version
return false if number.blank? return false if number.blank?
return false if number =~ /^[2-5]\./ return false if number.match?(/^[2-5]\./)
true true
end end
@ -308,7 +308,7 @@ end
def es_type_in_mapping? def es_type_in_mapping?
number = es_version number = es_version
return true if number.blank? return true if number.blank?
return true if number =~ /^[2-6]\./ return true if number.match?(/^[2-6]\./)
false false
end end

View file

@ -698,7 +698,7 @@ process webhook messages from twitter
channel.options[:sync][:search].each do |local_search| channel.options[:sync][:search].each do |local_search|
next if local_search[:term].blank? next if local_search[:term].blank?
next if local_search[:group_id].blank? next if local_search[:group_id].blank?
next if item['text'] !~ /#{Regexp.quote(local_search[:term])}/i next if !item['text'].match?(/#{Regexp.quote(local_search[:term])}/i)
group_id = local_search[:group_id] group_id = local_search[:group_id]
break break

View file

@ -1179,7 +1179,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab)
cookies = instance.manage.all_cookies cookies = instance.manage.all_cookies
cookies.each do |cookie| cookies.each do |cookie|
# :name=>"_zammad_session_c25832f4de2", :value=>"adc31cd21615cb0a7ab269184ec8b76f", :path=>"/", :domain=>"localhost", :expires=>nil, :secure=>false} # :name=>"_zammad_session_c25832f4de2", :value=>"adc31cd21615cb0a7ab269184ec8b76f", :path=>"/", :domain=>"localhost", :expires=>nil, :secure=>false}
next if cookie[:name] !~ /#{params[:name]}/i next if !cookie[:name].match?(/#{params[:name]}/i)
if params.key?(:value) && cookie[:value].to_s =~ /#{params[:value]}/i if params.key?(:value) && cookie[:value].to_s =~ /#{params[:value]}/i
assert(true, "matching value '#{params[:value]}' in cookie '#{cookie}'") assert(true, "matching value '#{params[:value]}' in cookie '#{cookie}'")

View file

@ -66,8 +66,8 @@ class ActiveSupport::TestCase
count = 0 count = 0
lines.reverse_each do |line| lines.reverse_each do |line|
break if line.match?(/\+\+\+\+NEW\+\+\+\+TEST\+\+\+\+/) break if line.match?(/\+\+\+\+NEW\+\+\+\+TEST\+\+\+\+/)
next if line !~ /Send notification \(#{type}\)/ next if !line.match?(/Send notification \(#{type}\)/)
next if line !~ /to:\s#{recipient}/ next if !line.match?(/to:\s#{recipient}/)
count += 1 count += 1
end end