Patch #28940 » match_final.patch
| app/controllers/application_controller.rb (working copy) | ||
|---|---|---|
| 114 | 114 |
if (key = api_key_from_request) |
| 115 | 115 |
# Use API key |
| 116 | 116 |
user = User.find_by_api_key(key) |
| 117 |
elsif request.authorization.to_s =~ /\ABasic /i
|
|
| 117 |
elsif /\ABasic /i.match?(request.authorization.to_s)
|
|
| 118 | 118 |
# HTTP Basic, either username/password or API key/random |
| 119 | 119 |
authenticate_with_http_basic do |username, password| |
| 120 | 120 |
user = User.try_to_login(username, password) || User.find_by_api_key(username) |
| ... | ... | |
| 441 | 441 |
path = uri.to_s |
| 442 | 442 |
# Ensure that the remaining URL starts with a slash, followed by a |
| 443 | 443 |
# non-slash character or the end |
| 444 |
if path !~ %r{\A/([^/]|\z)}
|
|
| 444 |
if !%r{\A/([^/]|\z)}.match?(path)
|
|
| 445 | 445 |
return false |
| 446 | 446 |
end |
| 447 | 447 | |
| 448 |
if path.match(%r{/(login|account/register|account/lost_password)})
|
|
| 448 |
if %r{/(login|account/register|account/lost_password)}.match?(path)
|
|
| 449 | 449 |
return false |
| 450 | 450 |
end |
| 451 | 451 | |
| ... | ... | |
| 626 | 626 | |
| 627 | 627 |
# Returns a string that can be used as filename value in Content-Disposition header |
| 628 | 628 |
def filename_for_content_disposition(name) |
| 629 |
request.env['HTTP_USER_AGENT'] =~ %r{(MSIE|Trident|Edge)} ? ERB::Util.url_encode(name) : name
|
|
| 629 |
%r{(MSIE|Trident|Edge)}.match?(request.env['HTTP_USER_AGENT']) ? ERB::Util.url_encode(name) : name
|
|
| 630 | 630 |
end |
| 631 | 631 | |
| 632 | 632 |
def api_request? |
| app/controllers/repositories_controller.rb (working copy) | ||
|---|---|---|
| 320 | 320 |
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip |
| 321 | 321 |
@rev_to = params[:rev_to] |
| 322 | 322 | |
| 323 |
unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
|
|
| 323 |
unless REV_PARAM_RE.match?(@rev.to_s) && REV_PARAM_RE.match?(@rev_to.to_s)
|
|
| 324 | 324 |
if @repository.branches.blank? |
| 325 | 325 |
raise InvalidRevisionParam |
| 326 | 326 |
end |
| app/controllers/sys_controller.rb (working copy) | ||
|---|---|---|
| 52 | 52 |
scope = Project.active.has_module(:repository) |
| 53 | 53 |
if params[:id] |
| 54 | 54 |
project = nil |
| 55 |
if params[:id].to_s =~ /^\d*$/
|
|
| 55 |
if /^\d*$/.match?(params[:id].to_s)
|
|
| 56 | 56 |
project = scope.find(params[:id]) |
| 57 | 57 |
else |
| 58 | 58 |
project = scope.find_by_identifier(params[:id]) |
| app/helpers/queries_helper.rb (working copy) | ||
|---|---|---|
| 30 | 30 |
group = :label_relations |
| 31 | 31 |
elsif field_options[:type] == :tree |
| 32 | 32 |
group = query.is_a?(IssueQuery) ? :label_relations : nil |
| 33 |
elsif field =~ /^cf_\d+\./
|
|
| 33 |
elsif /^cf_\d+\./.match?(field)
|
|
| 34 | 34 |
group = (field_options[:through] || field_options[:field]).try(:name) |
| 35 | 35 |
elsif field =~ /^(.+)\./ |
| 36 | 36 |
# association filters |
| app/models/attachment.rb (working copy) | ||
|---|---|---|
| 245 | 245 |
end |
| 246 | 246 | |
| 247 | 247 |
def is_diff? |
| 248 |
self.filename =~ /\.(patch|diff)$/i
|
|
| 248 |
/\.(patch|diff)$/i.match?(filename)
|
|
| 249 | 249 |
end |
| 250 | 250 | |
| 251 | 251 |
def is_pdf? |
| ... | ... | |
| 494 | 494 |
def self.disk_filename(filename, directory=nil) |
| 495 | 495 |
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
| 496 | 496 |
ascii = '' |
| 497 |
if filename =~ %r{^[a-zA-Z0-9_\.\-]*$} && filename.length <= 50
|
|
| 497 |
if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50
|
|
| 498 | 498 |
ascii = filename |
| 499 | 499 |
else |
| 500 | 500 |
ascii = Digest::MD5.hexdigest(filename) |
| app/models/import.rb (working copy) | ||
|---|---|---|
| 79 | 79 |
# Returns the full path of the file to import |
| 80 | 80 |
# It is stored in tmp/imports with a random hex as filename |
| 81 | 81 |
def filepath |
| 82 |
if filename.present? && filename =~ /\A[0-9a-f]+\z/
|
|
| 82 |
if filename.present? && /\A[0-9a-f]+\z/.match?(filename)
|
|
| 83 | 83 |
File.join(Rails.root, "tmp", "imports", filename) |
| 84 | 84 |
else |
| 85 | 85 |
nil |
| app/models/issue.rb (working copy) | ||
|---|---|---|
| 528 | 528 | |
| 529 | 529 |
# Project and Tracker must be set before since new_statuses_allowed_to depends on it. |
| 530 | 530 |
if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
|
| 531 |
if p.is_a?(String) && !p.match(/^\d*$/)
|
|
| 531 |
if p.is_a?(String) && !/^\d*$/.match?(p)
|
|
| 532 | 532 |
p_id = Project.find_by_identifier(p).try(:id) |
| 533 | 533 |
else |
| 534 | 534 |
p_id = p.to_i |
| ... | ... | |
| 769 | 769 |
user = new_record? ? author : current_journal.try(:user) |
| 770 | 770 | |
| 771 | 771 |
required_attribute_names(user).each do |attribute| |
| 772 |
if attribute =~ /^\d+$/
|
|
| 772 |
if /^\d+$/.match?(attribute)
|
|
| 773 | 773 |
attribute = attribute.to_i |
| 774 | 774 |
v = custom_field_values.detect {|v| v.custom_field_id == attribute }
|
| 775 | 775 |
if v && Array(v.value).detect(&:present?).nil? |
| app/models/mail_handler.rb (working copy) | ||
|---|---|---|
| 103 | 103 |
value = email.header[key] |
| 104 | 104 |
if value |
| 105 | 105 |
value = value.to_s.downcase |
| 106 |
if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value
|
|
| 106 |
if (ignored_value.is_a?(Regexp) && ignored_value.match?(value)) || value == ignored_value
|
|
| 107 | 107 |
if logger |
| 108 | 108 |
logger.info "MailHandler: ignoring email with #{key}:#{value} header"
|
| 109 | 109 |
end |
| ... | ... | |
| 316 | 316 |
else |
| 317 | 317 |
regexp = %r{\A#{Regexp.escape(pattern).gsub("\\*", ".*")}\z}i
|
| 318 | 318 |
end |
| 319 |
if attachment.filename.to_s =~ regexp
|
|
| 319 |
if regexp.match?(attachment.filename.to_s)
|
|
| 320 | 320 |
logger.info "MailHandler: ignoring attachment #{attachment.filename} matching #{pattern}"
|
| 321 | 321 |
return false |
| 322 | 322 |
end |
| app/models/principal.rb (working copy) | ||
|---|---|---|
| 176 | 176 |
principal ||= principals.detect {|a| keyword.casecmp(a.login.to_s) == 0}
|
| 177 | 177 |
principal ||= principals.detect {|a| keyword.casecmp(a.mail.to_s) == 0}
|
| 178 | 178 | |
| 179 |
if principal.nil? && keyword.match(/ /)
|
|
| 179 |
if principal.nil? && / /.match?(keyword)
|
|
| 180 | 180 |
firstname, lastname = *(keyword.split) # "First Last Throwaway" |
| 181 | 181 |
principal ||= principals.detect {|a|
|
| 182 | 182 |
a.is_a?(User) && |
| app/models/project.rb (working copy) | ||
|---|---|---|
| 313 | 313 |
end |
| 314 | 314 | |
| 315 | 315 |
def self.find(*args) |
| 316 |
if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/)
|
|
| 316 |
if args.first && args.first.is_a?(String) && !/^\d*$/.match?(args.first)
|
|
| 317 | 317 |
project = find_by_identifier(*args) |
| 318 | 318 |
raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil?
|
| 319 | 319 |
project |
| ... | ... | |
| 353 | 353 |
nil |
| 354 | 354 |
else |
| 355 | 355 |
# id is used for projects with a numeric identifier (compatibility) |
| 356 |
@to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier)
|
|
| 356 |
@to_param ||= (%r{^\d*$}.match?(identifier.to_s) ? id.to_s : identifier)
|
|
| 357 | 357 |
end |
| 358 | 358 |
end |
| 359 | 359 | |
| app/models/query.rb (working copy) | ||
|---|---|---|
| 439 | 439 |
if values_for(field) |
| 440 | 440 |
case type_for(field) |
| 441 | 441 |
when :integer |
| 442 |
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(,[+-]?\d+)*\z/) }
|
|
| 442 |
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/\A[+-]?\d+(,[+-]?\d+)*\z/.match?(v) }
|
|
| 443 | 443 |
when :float |
| 444 |
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\.\d*)?\z/) }
|
|
| 444 |
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/\A[+-]?\d+(\.\d*)?\z/.match?(v) }
|
|
| 445 | 445 |
when :date, :date_past |
| 446 | 446 |
case operator_for(field) |
| 447 | 447 |
when "=", ">=", "<=", "><" |
| 448 | 448 |
add_filter_error(field, :invalid) if values_for(field).detect {|v|
|
| 449 |
v.present? && (!v.match(/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/) || parse_date(v).nil?)
|
|
| 449 |
v.present? && (!/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/.match?(v) || parse_date(v).nil?)
|
|
| 450 | 450 |
} |
| 451 | 451 |
when ">t-", "<t-", "t-", ">t+", "<t+", "t+", "><t+", "><t-" |
| 452 |
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
|
|
| 452 |
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/^\d+$/.match?(v) }
|
|
| 453 | 453 |
end |
| 454 | 454 |
end |
| 455 | 455 |
end |
| ... | ... | |
| 1053 | 1053 |
raise "Unknown #{queried_class.name} association #{assoc}" unless customized_class
|
| 1054 | 1054 |
end |
| 1055 | 1055 |
where = sql_for_field(field, operator, value, db_table, db_field, true) |
| 1056 |
if operator =~ /[<>]/
|
|
| 1056 |
if /[<>]/.match?(operator)
|
|
| 1057 | 1057 |
where = "(#{where}) AND #{db_table}.#{db_field} <> ''"
|
| 1058 | 1058 |
end |
| 1059 | 1059 |
"#{queried_table_name}.#{customized_key} #{not_in} IN (" +
|
| ... | ... | |
| 1398 | 1398 | |
| 1399 | 1399 |
# Returns a Date or Time from the given filter value |
| 1400 | 1400 |
def parse_date(arg) |
| 1401 |
if arg.to_s =~ /\A\d{4}-\d{2}-\d{2}T/
|
|
| 1401 |
if /\A\d{4}-\d{2}-\d{2}T/.match?(arg.to_s)
|
|
| 1402 | 1402 |
Time.parse(arg) rescue nil |
| 1403 | 1403 |
else |
| 1404 | 1404 |
Date.parse(arg) rescue nil |
| app/models/repository.rb (working copy) | ||
|---|---|---|
| 149 | 149 |
end |
| 150 | 150 | |
| 151 | 151 |
def self.find_by_identifier_param(param) |
| 152 |
if param.to_s =~ /^\d+$/
|
|
| 152 |
if /^\d+$/.match?(param.to_s)
|
|
| 153 | 153 |
find_by_id(param) |
| 154 | 154 |
else |
| 155 | 155 |
find_by_identifier(param) |
| ... | ... | |
| 248 | 248 |
def find_changeset_by_name(name) |
| 249 | 249 |
return nil if name.blank? |
| 250 | 250 |
s = name.to_s |
| 251 |
if s.match(/^\d*$/)
|
|
| 251 |
if /^\d*$/.match?(s)
|
|
| 252 | 252 |
changesets.find_by(:revision => s) |
| 253 | 253 |
else |
| 254 | 254 |
changesets.where("revision LIKE ?", s + '%').first
|
| ... | ... | |
| 469 | 469 |
regexp = Redmine::Configuration["scm_#{scm_name.to_s.downcase}_path_regexp"]
|
| 470 | 470 |
if changes[attribute] && regexp.present? |
| 471 | 471 |
regexp = regexp.to_s.strip.gsub('%project%') {Regexp.escape(project.try(:identifier).to_s)}
|
| 472 |
unless send(attribute).to_s.match(Regexp.new("\\A#{regexp}\\z"))
|
|
| 472 |
unless Regexp.new("\\A#{regexp}\\z").match?(send(attribute).to_s)
|
|
| 473 | 473 |
errors.add(attribute, :invalid) |
| 474 | 474 |
end |
| 475 | 475 |
end |
| app/models/repository/mercurial.rb (working copy) | ||
|---|---|---|
| 98 | 98 |
def find_changeset_by_name(name) |
| 99 | 99 |
return nil if name.blank? |
| 100 | 100 |
s = name.to_s |
| 101 |
if /[^\d]/ =~ s or s.size > 8
|
|
| 101 |
if /[^\d]/.match?(s) || s.size > 8
|
|
| 102 | 102 |
cs = changesets.where(:scmid => s).first |
| 103 | 103 |
else |
| 104 | 104 |
cs = changesets.find_by(:revision => s) |
| app/models/token.rb (working copy) | ||
|---|---|---|
| 112 | 112 |
def self.find_token(action, key, validity_days=nil) |
| 113 | 113 |
action = action.to_s |
| 114 | 114 |
key = key.to_s |
| 115 |
return nil unless action.present? && key =~ /\A[a-z0-9]+\z/i
|
|
| 115 |
return nil unless action.present? && /\A[a-z0-9]+\z/i.match?(key)
|
|
| 116 | 116 | |
| 117 | 117 |
token = Token.find_by(:action => action, :value => key) |
| 118 | 118 |
if token && (token.action == action) && (token.value == key) && token.user |
| app/models/workflow_permission.rb (working copy) | ||
|---|---|---|
| 64 | 64 |
protected |
| 65 | 65 | |
| 66 | 66 |
def validate_field_name |
| 67 |
unless Tracker::CORE_FIELDS_ALL.include?(field_name) || field_name.to_s.match(/^\d+$/)
|
|
| 67 |
unless Tracker::CORE_FIELDS_ALL.include?(field_name) || /^\d+$/.match?(field_name.to_s)
|
|
| 68 | 68 |
errors.add :field_name, :invalid |
| 69 | 69 |
end |
| 70 | 70 |
end |
| lib/plugins/open_id_authentication/lib/open_id_authentication.rb (working copy) | ||
|---|---|---|
| 87 | 87 |
# dodge XRIs -- TODO: validate, don't just skip. |
| 88 | 88 |
unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0))
|
| 89 | 89 |
# does it begin with http? if not, add it. |
| 90 |
identifier = +"http://#{identifier}" unless identifier =~ /^http/i
|
|
| 90 |
identifier = +"http://#{identifier}" unless /^http/i.match?(identifier)
|
|
| 91 | 91 | |
| 92 | 92 |
# strip any fragments |
| 93 | 93 |
identifier.gsub!(/\#(.*)$/, '') |
| lib/redmine/codeset_util.rb (working copy) | ||
|---|---|---|
| 42 | 42 |
return if str.nil? |
| 43 | 43 |
str = str.b |
| 44 | 44 |
return str if str.empty? |
| 45 |
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii |
|
| 45 |
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match?(str) # for us-ascii
|
|
| 46 | 46 |
str.force_encoding('UTF-8')
|
| 47 | 47 |
encodings = Setting.repositories_encodings.split(',').collect(&:strip)
|
| 48 | 48 |
encodings.each do |encoding| |
| lib/redmine/configuration.rb (working copy) | ||
|---|---|---|
| 122 | 122 |
# Checks the validness of regular expressions set for repository paths at startup |
| 123 | 123 |
def check_regular_expressions |
| 124 | 124 |
@config.each do |name, value| |
| 125 |
if value.present? && name =~ /^scm_.+_path_regexp$/
|
|
| 125 |
if value.present? && /^scm_.+_path_regexp$/.match?(name)
|
|
| 126 | 126 |
begin |
| 127 | 127 |
Regexp.new value.to_s.strip |
| 128 | 128 |
rescue => e |
| lib/redmine/core_ext/active_record.rb (working copy) | ||
|---|---|---|
| 21 | 21 |
def validate_each(record, attribute, value) |
| 22 | 22 |
before_type_cast = record.attributes_before_type_cast[attribute.to_s] |
| 23 | 23 |
if before_type_cast.is_a?(String) && before_type_cast.present? |
| 24 |
unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/ && value
|
|
| 24 |
unless /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/.match?(before_type_cast) && value
|
|
| 25 | 25 |
record.errors.add attribute, :not_a_date |
| 26 | 26 |
end |
| 27 | 27 |
end |
| lib/redmine/database.rb (working copy) | ||
|---|---|---|
| 23 | 23 |
class << self |
| 24 | 24 |
# Returns true if the database is PostgreSQL |
| 25 | 25 |
def postgresql? |
| 26 |
(ActiveRecord::Base.connection.adapter_name =~ /postgresql/i).present?
|
|
| 26 |
/postgresql/i.match?(ActiveRecord::Base.connection.adapter_name)
|
|
| 27 | 27 |
end |
| 28 | 28 | |
| 29 | 29 |
# Returns the PostgreSQL version or nil if another DBMS is used |
| ... | ... | |
| 48 | 48 | |
| 49 | 49 |
# Returns true if the database is MySQL |
| 50 | 50 |
def mysql? |
| 51 |
(ActiveRecord::Base.connection.adapter_name =~ /mysql/i).present?
|
|
| 51 |
/mysql/i.match?(ActiveRecord::Base.connection.adapter_name)
|
|
| 52 | 52 |
end |
| 53 | 53 | |
| 54 | 54 |
# Returns a SQL statement for case/accent (if possible) insensitive match |
| lib/redmine/export/pdf.rb (working copy) | ||
|---|---|---|
| 140 | 140 |
def self.attach(attachments, filename, encoding) |
| 141 | 141 |
filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding) |
| 142 | 142 |
atta = nil |
| 143 |
if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
|
|
| 143 |
if /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i.match?(filename_utf8)
|
|
| 144 | 144 |
atta = Attachment.latest_attach(attachments, filename_utf8) |
| 145 | 145 |
end |
| 146 | 146 |
if atta && atta.readable? && atta.visible? |
| lib/redmine/field_format.rb (working copy) | ||
|---|---|---|
| 251 | 251 |
[text, url] |
| 252 | 252 |
end |
| 253 | 253 |
links = texts_and_urls.sort_by(&:first).map do |text, url| |
| 254 |
css_class = (url =~ /^https?:\/\//) ? 'external' : nil
|
|
| 254 |
css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil
|
|
| 255 | 255 |
view.link_to_if uri_with_safe_scheme?(url), text, url, :class => css_class |
| 256 | 256 |
end |
| 257 | 257 |
links.join(', ').html_safe
|
| ... | ... | |
| 360 | 360 |
def validate_single_value(custom_field, value, customized=nil) |
| 361 | 361 |
errs = super |
| 362 | 362 |
value = value.to_s |
| 363 |
unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
|
|
| 363 |
unless custom_field.regexp.blank? or Regexp.new(custom_field.regexp).match?(value)
|
|
| 364 | 364 |
errs << ::I18n.t('activerecord.errors.messages.invalid')
|
| 365 | 365 |
end |
| 366 | 366 |
if custom_field.min_length && value.length < custom_field.min_length |
| ... | ... | |
| 442 | 442 |
url = url_from_pattern(custom_field, value, customized) |
| 443 | 443 |
else |
| 444 | 444 |
url = value.to_s |
| 445 |
unless url =~ %r{\A[a-z]+://}i
|
|
| 445 |
unless %r{\A[a-z]+://}i.match?(url)
|
|
| 446 | 446 |
# no protocol found, use http by default |
| 447 | 447 |
url = "http://" + url |
| 448 | 448 |
end |
| 449 | 449 |
end |
| 450 |
css_class = (url =~ /^https?:\/\//) ? 'external' : nil
|
|
| 450 |
css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil
|
|
| 451 | 451 |
view.link_to value.to_s.truncate(40), url, :class => css_class |
| 452 | 452 |
else |
| 453 | 453 |
value.to_s |
| ... | ... | |
| 492 | 492 | |
| 493 | 493 |
def validate_single_value(custom_field, value, customized=nil) |
| 494 | 494 |
errs = super |
| 495 |
errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s.strip =~ /^[+-]?\d+$/
|
|
| 495 |
errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless /^[+-]?\d+$/.match?(value.to_s.strip)
|
|
| 496 | 496 |
errs |
| 497 | 497 |
end |
| 498 | 498 | |
| ... | ... | |
| 536 | 536 |
end |
| 537 | 537 | |
| 538 | 538 |
def validate_single_value(custom_field, value, customized=nil) |
| 539 |
if value =~ /^\d{4}-\d{2}-\d{2}$/ && (value.to_date rescue false)
|
|
| 539 |
if /^\d{4}-\d{2}-\d{2}$/.match?(value) && (value.to_date rescue false)
|
|
| 540 | 540 |
[] |
| 541 | 541 |
else |
| 542 | 542 |
[::I18n.t('activerecord.errors.messages.not_a_date')]
|
| lib/redmine/nested_set/issue_nested_set.rb (working copy) | ||
|---|---|---|
| 151 | 151 |
end |
| 152 | 152 | |
| 153 | 153 |
def lock_nested_set |
| 154 |
if self.class.connection.adapter_name =~ /sqlserver/i
|
|
| 154 |
if /sqlserver/i.match?(self.class.connection.adapter_name)
|
|
| 155 | 155 |
lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)" |
| 156 | 156 |
# Custom lock for SQLServer |
| 157 | 157 |
# This can be problematic if root_id or parent root_id changes |
| lib/redmine/nested_set/project_nested_set.rb (working copy) | ||
|---|---|---|
| 121 | 121 | |
| 122 | 122 |
def lock_nested_set |
| 123 | 123 |
lock = true |
| 124 |
if self.class.connection.adapter_name =~ /sqlserver/i
|
|
| 124 |
if /sqlserver/i.match?(self.class.connection.adapter_name)
|
|
| 125 | 125 |
lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)" |
| 126 | 126 |
end |
| 127 | 127 |
self.class.order(:id).lock(lock).ids |
| lib/redmine/platform.rb (working copy) | ||
|---|---|---|
| 21 | 21 |
module Platform |
| 22 | 22 |
class << self |
| 23 | 23 |
def mswin? |
| 24 |
(RUBY_PLATFORM =~ /(:?mswin|mingw)/) ||
|
|
| 25 |
(RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i)
|
|
| 24 |
(/(:?mswin|mingw)/.match?(RUBY_PLATFORM)) ||
|
|
| 25 |
(RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os']))
|
|
| 26 | 26 |
end |
| 27 | 27 |
end |
| 28 | 28 |
end |
| lib/redmine/scm/adapters/abstract_adapter.rb (working copy) | ||
|---|---|---|
| 186 | 186 | |
| 187 | 187 |
def target(path, sq=true) |
| 188 | 188 |
path ||= '' |
| 189 |
base = path.match(/^\//) ? root_url : url
|
|
| 189 |
base = /^\//.match?(path) ? root_url : url
|
|
| 190 | 190 |
str = "#{base}/#{path}".gsub(/[?<>\*]/, '')
|
| 191 | 191 |
if sq |
| 192 | 192 |
str = shell_quote(str) |
| lib/redmine/scm/adapters/cvs_adapter.rb (working copy) | ||
|---|---|---|
| 170 | 170 |
file_state = nil |
| 171 | 171 |
branch_map = nil |
| 172 | 172 |
io.each_line() do |line| |
| 173 |
if state != "revision" && /^#{ENDLOG}/ =~ line
|
|
| 173 |
if state != "revision" && /^#{ENDLOG}/.match?(line)
|
|
| 174 | 174 |
commit_log = "" |
| 175 | 175 |
revision = nil |
| 176 | 176 |
state = "entry_start" |
| ... | ... | |
| 183 | 183 |
logger.debug("Path #{entry_path} <=> Name #{entry_name}")
|
| 184 | 184 |
elsif /^head: (.+)$/ =~ line |
| 185 | 185 |
entry_headRev = $1 #unless entry.nil? |
| 186 |
elsif /^symbolic names:/ =~ line
|
|
| 186 |
elsif /^symbolic names:/.match?(line)
|
|
| 187 | 187 |
state = "symbolic" #unless entry.nil? |
| 188 |
elsif /^#{STARTLOG}/ =~ line
|
|
| 188 |
elsif /^#{STARTLOG}/.match?(line)
|
|
| 189 | 189 |
commit_log = "" |
| 190 | 190 |
state = "revision" |
| 191 | 191 |
end |
| lib/redmine/scm/adapters/filesystem_adapter.rb (working copy) | ||
|---|---|---|
| 109 | 109 |
# Here we do not shell-out, so we do not want quotes. |
| 110 | 110 |
def target(path=nil) |
| 111 | 111 |
# Prevent the use of .. |
| 112 |
if path and !path.match(/(^|\/)\.\.(\/|$)/)
|
|
| 112 |
if path and !/(^|\/)\.\.(\/|$)/.match?(path)
|
|
| 113 | 113 |
return "#{self.url}#{without_leading_slash(path)}"
|
| 114 | 114 |
end |
| 115 | 115 |
return self.url |
| lib/redmine/scm/adapters/mercurial_adapter.rb (working copy) | ||
|---|---|---|
| 297 | 297 |
# Runs 'hg' command with the given args |
| 298 | 298 |
def hg(*args, &block) |
| 299 | 299 |
# as of hg 4.4.1, early parsing of bool options is not terminated at '--' |
| 300 |
if args.any? { |s| s =~ HG_EARLY_BOOL_ARG }
|
|
| 300 |
if args.any? { |s| HG_EARLY_BOOL_ARG.match?(s) }
|
|
| 301 | 301 |
raise HgCommandArgumentError, "malicious command argument detected" |
| 302 | 302 |
end |
| 303 |
if args.take_while { |s| s != '--' }.any? { |s| s =~ HG_EARLY_LIST_ARG }
|
|
| 303 |
if args.take_while { |s| s != '--' }.any? { |s| HG_EARLY_LIST_ARG.match?(s) }
|
|
| 304 | 304 |
raise HgCommandArgumentError, "malicious command argument detected" |
| 305 | 305 |
end |
| 306 | 306 | |
| lib/redmine/scm/adapters/subversion_adapter.rb (working copy) | ||
|---|---|---|
| 267 | 267 |
end |
| 268 | 268 | |
| 269 | 269 |
def target(path = '') |
| 270 |
base = path.match(/^\//) ? root_url : url
|
|
| 270 |
base = /^\//.match?(path) ? root_url : url
|
|
| 271 | 271 |
uri = "#{base}/#{path}"
|
| 272 | 272 |
uri = URI.escape(URI.escape(uri), '[]') |
| 273 | 273 |
shell_quote(uri.gsub(/[?<>\*]/, '')) |
| lib/redmine/sort_criteria.rb (working copy) | ||
|---|---|---|
| 96 | 96 | |
| 97 | 97 |
# Appends ASC/DESC to the sort criterion unless it has a fixed order |
| 98 | 98 |
def append_order(criterion, order) |
| 99 |
if criterion =~ / (asc|desc)$/i
|
|
| 99 |
if / (asc|desc)$/i.match?(criterion)
|
|
| 100 | 100 |
criterion |
| 101 | 101 |
else |
| 102 | 102 |
Arel.sql "#{criterion} #{order.to_s.upcase}"
|
| lib/redmine/unified_diff.rb (working copy) | ||
|---|---|---|
| 78 | 78 |
@parsing = true |
| 79 | 79 |
end |
| 80 | 80 |
else |
| 81 |
if line =~ %r{^[^\+\-\s@\\]}
|
|
| 81 |
if %r{^[^\+\-\s@\\]}.match?(line)
|
|
| 82 | 82 |
@parsing = false |
| 83 | 83 |
return false |
| 84 | 84 |
elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/ |
| ... | ... | |
| 114 | 114 |
def file_name=(arg) |
| 115 | 115 |
both_git_diff = false |
| 116 | 116 |
if file_name.nil? |
| 117 |
@git_diff = true if arg =~ %r{^(a/|/dev/null)}
|
|
| 117 |
@git_diff = true if %r{^(a/|/dev/null)}.match?(arg)
|
|
| 118 | 118 |
else |
| 119 |
both_git_diff = (@git_diff && arg =~ %r{^(b/|/dev/null)})
|
|
| 119 |
both_git_diff = (@git_diff && %r{^(b/|/dev/null)}.match?(arg))
|
|
| 120 | 120 |
end |
| 121 | 121 |
if both_git_diff |
| 122 | 122 |
if file_name && arg == "/dev/null" |
| ... | ... | |
| 168 | 168 |
true |
| 169 | 169 |
else |
| 170 | 170 |
write_offsets |
| 171 |
if line[0, 1] =~ /\s/
|
|
| 171 |
if /\s/.match?(line[0, 1])
|
|
| 172 | 172 |
diff = Diff.new |
| 173 | 173 |
diff.line_right = line[1..-1] |
| 174 | 174 |
diff.nb_line_right = @line_num_r |
| lib/redmine/wiki_formatting.rb (working copy) | ||
|---|---|---|
| 135 | 135 |
def auto_link!(text) |
| 136 | 136 |
text.gsub!(AUTO_LINK_RE) do |
| 137 | 137 |
all, leading, proto, url, post = $&, $1, $2, $3, $6 |
| 138 |
if leading =~ /<a\s/i || leading =~ /![<>=]?/
|
|
| 138 |
if /<a\s/i.match?(leading) || /![<>=]?/.match?(leading)
|
|
| 139 | 139 |
# don't replace URLs that are already linked |
| 140 | 140 |
# and URLs prefixed with ! !> !< != (textile images) |
| 141 | 141 |
all |
| ... | ... | |
| 157 | 157 |
def auto_mailto!(text) |
| 158 | 158 |
text.gsub!(/([\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do |
| 159 | 159 |
mail = $1 |
| 160 |
if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
|
|
| 160 |
if /<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/.match?(text)
|
|
| 161 | 161 |
|
| 162 | 162 |
else |
| 163 | 163 |
%(<a class="email" href="mailto:#{ERB::Util.html_escape mail}">#{ERB::Util.html_escape mail}</a>).html_safe
|
| lib/redmine/wiki_formatting/macros.rb (working copy) | ||
|---|---|---|
| 143 | 143 |
# If a block of text is given, the closing tag }} must be at the start of a new line. |
| 144 | 144 |
def macro(name, options={}, &block)
|
| 145 | 145 |
options.assert_valid_keys(:desc, :parse_args) |
| 146 |
unless name.to_s.match(/\A\w+\z/)
|
|
| 146 |
unless /\A\w+\z/.match?(name.to_s)
|
|
| 147 | 147 |
raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
|
| 148 | 148 |
end |
| 149 | 149 |
unless block_given? |
| ... | ... | |
| 240 | 240 |
filename = args.first |
| 241 | 241 |
raise 'Filename required' unless filename.present? |
| 242 | 242 |
size = options[:size] |
| 243 |
raise 'Invalid size parameter' unless size.nil? || size.match(/^\d+$/)
|
|
| 243 |
raise 'Invalid size parameter' unless size.nil? || /^\d+$/.match?(size)
|
|
| 244 | 244 |
size = size.to_i |
| 245 | 245 |
size = 200 unless size > 0 |
| 246 | 246 |
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename) |
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »