Feature #26561 » frozen.patch
| app/controllers/journals_controller.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
# Replaces pre blocks with [...]
|
||
|
text = text.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]')
|
||
|
@content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||
|
@content = +"#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||
|
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
| app/controllers/messages_controller.rb (working copy) | ||
|---|---|---|
|
@subject = @message.subject
|
||
|
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
|
||
|
@content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
|
||
|
@content = +"#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
|
||
|
@content << @message.content.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||
|
end
|
||
| app/controllers/search_controller.rb (working copy) | ||
|---|---|---|
|
accept_api_auth :index
|
||
|
def index
|
||
|
@question = params[:q] || ""
|
||
|
@question = params[:q] || +""
|
||
|
@question.strip!
|
||
|
@all_words = params[:all_words] ? params[:all_words].present? : true
|
||
|
@titles_only = params[:titles_only] ? params[:titles_only].present? : false
|
||
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def toggle_link(name, id, options={})
|
||
|
onclick = "$('##{id}').toggle(); "
|
||
|
onclick = +"$('##{id}').toggle(); "
|
||
|
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
|
||
|
onclick << "$(window).scrollTop($('##{options[:focus]}').position().top); " if options[:scroll]
|
||
|
onclick << "return false;"
|
||
| ... | ... | |
|
# The given collection may be a subset of the whole project tree
|
||
|
# (eg. some intermediate nodes are private and can not be seen)
|
||
|
def render_project_nested_lists(projects, &block)
|
||
|
s = ''
|
||
|
s = +''
|
||
|
if projects.any?
|
||
|
ancestors = []
|
||
|
original_project = @project
|
||
| ... | ... | |
|
end
|
||
|
def render_page_hierarchy(pages, node=nil, options={})
|
||
|
content = ''
|
||
|
content = +''
|
||
|
if pages[node]
|
||
|
content << "<ul class=\"pages-hierarchy\">\n"
|
||
|
pages[node].each do |page|
|
||
| ... | ... | |
|
# Renders flash messages
|
||
|
def render_flash_messages
|
||
|
s = ''
|
||
|
s = +''
|
||
|
flash.each do |k,v|
|
||
|
s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
|
||
|
end
|
||
| ... | ... | |
|
def render_projects_for_jump_box(projects, selected=nil)
|
||
|
jump = params[:jump].presence || current_menu_item
|
||
|
s = ''.html_safe
|
||
|
s = (+'').html_safe
|
||
|
project_tree(projects) do |project, level|
|
||
|
padding = level * 16
|
||
|
text = content_tag('span', project.name, :style => "padding-left:#{padding}px;")
|
||
| ... | ... | |
|
end
|
||
|
def principals_check_box_tags(name, principals)
|
||
|
s = ''
|
||
|
s = +''
|
||
|
principals.each do |principal|
|
||
|
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
|
||
|
end
|
||
| ... | ... | |
|
# Returns a string for users/groups option tags
|
||
|
def principals_options_for_select(collection, selected=nil)
|
||
|
s = ''
|
||
|
s = +''
|
||
|
if collection.include?(User.current)
|
||
|
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
|
||
|
end
|
||
|
groups = ''
|
||
|
groups = +''
|
||
|
collection.sort.each do |element|
|
||
|
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected
|
||
|
(element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
|
||
| ... | ... | |
|
def parse_non_pre_blocks(text, obj, macros)
|
||
|
s = StringScanner.new(text)
|
||
|
tags = []
|
||
|
parsed = ''
|
||
|
parsed = +''
|
||
|
while !s.eos?
|
||
|
s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im)
|
||
|
text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
|
||
| ... | ... | |
|
if headings.empty?
|
||
|
''
|
||
|
else
|
||
|
div_class = 'toc'
|
||
|
div_class = +'toc'
|
||
|
div_class << ' right' if right_align
|
||
|
div_class << ' left' if left_align
|
||
|
out = "<ul class=\"#{div_class}\"><li><strong>#{l :label_table_of_contents}</strong></li><li>"
|
||
|
out = +"<ul class=\"#{div_class}\"><li><strong>#{l :label_table_of_contents}</strong></li><li>"
|
||
|
root = headings.map(&:first).min
|
||
|
current = root
|
||
|
started = false
|
||
| ... | ... | |
|
# Renders a list of error messages
|
||
|
def render_error_messages(errors)
|
||
|
html = ""
|
||
|
html = +""
|
||
|
if errors.present?
|
||
|
html << "<div id='errorExplanation'><ul>\n"
|
||
|
errors.each do |error|
|
||
| app/helpers/calendars_helper.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def calendar_day_css_classes(calendar, day)
|
||
|
css = day.month==calendar.month ? 'even' : 'odd'
|
||
|
css = day.month==calendar.month ? +'even' : +'odd'
|
||
|
css << " today" if User.current.today == day
|
||
|
css << " nwday" if non_working_week_days.include?(day.cwday)
|
||
|
css
|
||
| app/helpers/context_menus_helper.rb (working copy) | ||
|---|---|---|
|
module ContextMenusHelper
|
||
|
def context_menu_link(name, url, options={})
|
||
|
options[:class] ||= ''
|
||
|
options[:class] = options[:class].dup if options[:class].frozen?
|
||
|
if options.delete(:selected)
|
||
|
options[:class] << ' icon-checked disabled'
|
||
|
options[:disabled] = true
|
||
| app/helpers/custom_fields_helper.rb (working copy) | ||
|---|---|---|
|
def custom_field_tag_name(prefix, custom_field)
|
||
|
name = "#{prefix}[custom_field_values][#{custom_field.id}]"
|
||
|
name << "[]" if custom_field.multiple?
|
||
|
name += "[]" if custom_field.multiple?
|
||
|
name
|
||
|
end
|
||
| ... | ... | |
|
# Return custom field html tag corresponding to its format
|
||
|
def custom_field_tag(prefix, custom_value)
|
||
|
css = "#{custom_value.custom_field.field_format}_cf"
|
||
|
css << ' wiki-edit' if custom_value.custom_field.full_text_formatting?
|
||
|
css += ' wiki-edit' if custom_value.custom_field.full_text_formatting?
|
||
|
custom_value.custom_field.format.edit_tag self,
|
||
|
custom_field_tag_id(prefix, custom_value.custom_field),
|
||
| app/helpers/issues_helper.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def render_issue_subject_with_tree(issue)
|
||
|
s = ''
|
||
|
s = +''
|
||
|
ancestors = issue.root? ? [] : issue.ancestors.visible.to_a
|
||
|
ancestors.each do |ancestor|
|
||
|
s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
|
||
| ... | ... | |
|
def render_descendants_tree(issue)
|
||
|
manage_relations = User.current.allowed_to?(:manage_subtasks, issue.project)
|
||
|
s = '<table class="list issues odd-even">'
|
||
|
s = +'<table class="list issues odd-even">'
|
||
|
issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level|
|
||
|
css = "issue issue-#{child.id} hascontextmenu #{child.css_classes}"
|
||
|
css = +"issue issue-#{child.id} hascontextmenu #{child.css_classes}"
|
||
|
css << " idnt idnt-#{level}" if level > 0
|
||
|
buttons = manage_relations ? link_to(l(:label_delete_link_to_subtask),
|
||
|
issue_path({:id => child.id, :issue => {:parent_issue_id => ''}, :back_url => issue_path(issue.id), :no_flash => '1'}),
|
||
| ... | ... | |
|
def render_issue_relations(issue, relations)
|
||
|
manage_relations = User.current.allowed_to?(:manage_issue_relations, issue.project)
|
||
|
s = ''.html_safe
|
||
|
s = (+'').html_safe
|
||
|
relations.each do |relation|
|
||
|
other_issue = relation.other_issue(issue)
|
||
|
css = "issue hascontextmenu #{other_issue.css_classes}"
|
||
| ... | ... | |
|
l_hours_short(issue.estimated_hours)
|
||
|
else
|
||
|
s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : ""
|
||
|
s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})"
|
||
|
s += " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})"
|
||
|
s.html_safe
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
link_to(l_hours_short(issue.spent_hours), path)
|
||
|
else
|
||
|
s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : ""
|
||
|
s << " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})"
|
||
|
s += " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})"
|
||
|
s.html_safe
|
||
|
end
|
||
|
end
|
||
| app/helpers/projects_helper.rb (working copy) | ||
|---|---|---|
|
selected = (parent_id.blank? ? nil : Project.find(parent_id))
|
||
|
end
|
||
|
options = ''
|
||
|
options = +''
|
||
|
options << "<option value=''> </option>" if project.allowed_parents.include?(nil)
|
||
|
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
|
||
|
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
|
||
|
end
|
||
|
def render_project_action_links
|
||
|
links = "".html_safe
|
||
|
links = (+"").html_safe
|
||
|
if User.current.allowed_to?(:add_project, nil, :global => true)
|
||
|
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
|
||
|
end
|
||
| app/helpers/queries_helper.rb (working copy) | ||
|---|---|---|
|
session_key = klass.name.underscore.to_sym
|
||
|
if params[:query_id].present?
|
||
|
cond = "project_id IS NULL"
|
||
|
cond << " OR project_id = #{@project.id}" if @project
|
||
|
@query = klass.where(cond).find(params[:query_id])
|
||
|
scope = klass.where(:project_id => nil)
|
||
|
scope = scope.or(klass.where(:project_id => @project)) if @project
|
||
|
@query = scope.find(params[:query_id])
|
||
|
raise ::Unauthorized unless @query.visible?
|
||
|
@query.project = @project
|
||
|
session[session_key] = {:id => @query.id, :project_id => @query.project_id} if use_session
|
||
| ... | ... | |
|
content_tag('h3', title) + "\n" +
|
||
|
content_tag('ul',
|
||
|
queries.collect {|query|
|
||
|
css = 'query'
|
||
|
css = +'query'
|
||
|
css << ' selected' if query == @query
|
||
|
content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
|
||
|
}.join("\n").html_safe,
|
||
| app/helpers/repositories_helper.rb (working copy) | ||
|---|---|---|
|
def render_changes_tree(tree)
|
||
|
return '' if tree.nil?
|
||
|
output = ''
|
||
|
output = +''
|
||
|
output << '<ul>'
|
||
|
tree.keys.sort.each do |file|
|
||
|
style = 'change'
|
||
|
style = +'change'
|
||
|
text = File.basename(h(file))
|
||
|
if s = tree[file][:s]
|
||
|
style << ' folder'
|
||
| app/helpers/search_helper.rb (working copy) | ||
|---|---|---|
|
return text unless text && tokens && !tokens.empty?
|
||
|
re_tokens = tokens.collect {|t| Regexp.escape(t)}
|
||
|
regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
|
||
|
result = ''
|
||
|
result = +''
|
||
|
text.split(regexp).each_with_index do |words, i|
|
||
|
if result.length > 1200
|
||
|
# maximum length of the preview reached
|
||
| app/helpers/wiki_helper.rb (working copy) | ||
|---|---|---|
|
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
|
||
|
pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
|
||
|
s = ''.html_safe
|
||
|
s = (+'').html_safe
|
||
|
if pages.has_key?(parent)
|
||
|
pages[parent].each do |page|
|
||
|
attrs = "value='#{page.id}'"
|
||
|
attrs = +"value='#{page.id}'"
|
||
|
attrs << " selected='selected'" if selected == page
|
||
|
indent = (level > 0) ? (' ' * level * 2 + '» ') : ''
|
||
| app/models/issue.rb (working copy) | ||
|---|---|---|
|
# Returns a string of css classes that apply to the issue
|
||
|
def css_classes(user=User.current)
|
||
|
s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
|
||
|
s = +"issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
|
||
|
s << ' closed' if closed?
|
||
|
s << ' overdue' if overdue?
|
||
|
s << ' child' if child?
|
||
| app/models/journal.rb (working copy) | ||
|---|---|---|
|
# Returns a string of css classes
|
||
|
def css_classes
|
||
|
s = 'journal'
|
||
|
s = +'journal'
|
||
|
s << ' has-notes' unless notes.blank?
|
||
|
s << ' has-details' unless details.blank?
|
||
|
s << ' private-notes' if private_notes?
|
||
| app/models/mailer.rb (working copy) | ||
|---|---|---|
|
@user = user
|
||
|
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||
|
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
|
||
|
subject << " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
|
||
|
subject << " #{issue.subject}"
|
||
|
subject += " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
|
||
|
subject += " #{issue.subject}"
|
||
|
mail :to => user,
|
||
|
:subject => subject
|
||
|
end
|
||
| ... | ... | |
|
references issue
|
||
|
@author = journal.user
|
||
|
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
|
||
|
s << "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
|
||
|
s << issue.subject
|
||
|
s += "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
|
||
|
s += issue.subject
|
||
|
@issue = issue
|
||
|
@user = user
|
||
|
@journal = journal
|
||
| app/models/principal.rb (working copy) | ||
|---|---|---|
|
where({})
|
||
|
else
|
||
|
pattern = "%#{q}%"
|
||
|
sql = "LOWER(#{table_name}.login) LIKE LOWER(:p)"
|
||
|
sql = +"LOWER(#{table_name}.login) LIKE LOWER(:p)"
|
||
|
sql << " OR #{table_name}.id IN (SELECT user_id FROM #{EmailAddress.table_name} WHERE LOWER(address) LIKE LOWER(:p))"
|
||
|
params = {:p => pattern}
|
||
| app/models/project.rb (working copy) | ||
|---|---|---|
|
base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
|
||
|
if !options[:skip_pre_condition] && perm && perm.project_module
|
||
|
# If the permission belongs to a project module, make sure the module is enabled
|
||
|
base_statement << " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em WHERE em.project_id = #{Project.table_name}.id AND em.name='#{perm.project_module}')"
|
||
|
base_statement += " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em WHERE em.project_id = #{Project.table_name}.id AND em.name='#{perm.project_module}')"
|
||
|
end
|
||
|
if project = options[:project]
|
||
|
project_statement = project.project_condition(options[:with_subprojects])
|
||
| ... | ... | |
|
end
|
||
|
def css_classes
|
||
|
s = 'project'
|
||
|
s = +'project'
|
||
|
s << ' root' if root?
|
||
|
s << ' child' if child?
|
||
|
s << (leaf? ? ' leaf' : ' parent')
|
||
| app/models/query.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
when "!*"
|
||
|
sql = "#{db_table}.#{db_field} IS NULL"
|
||
|
sql << " OR #{db_table}.#{db_field} = ''" if (is_custom_filter || [:text, :string].include?(type_for(field)))
|
||
|
sql += " OR #{db_table}.#{db_field} = ''" if (is_custom_filter || [:text, :string].include?(type_for(field)))
|
||
|
when "*"
|
||
|
sql = "#{db_table}.#{db_field} IS NOT NULL"
|
||
|
sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
|
||
|
sql += " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
|
||
|
when ">="
|
||
|
if [:date, :date_past].include?(type_for(field))
|
||
|
sql = date_clause(db_table, db_field, parse_date(value.first), nil, is_custom_filter)
|
||
| app/models/repository.rb (working copy) | ||
|---|---|---|
|
def diff_format_revisions(cs, cs_to, sep=':')
|
||
|
text = ""
|
||
|
text << cs_to.format_identifier + sep if cs_to
|
||
|
text << cs.format_identifier if cs
|
||
|
text += cs_to.format_identifier + sep if cs_to
|
||
|
text += cs.format_identifier if cs
|
||
|
text
|
||
|
end
|
||
| app/models/user.rb (working copy) | ||
|---|---|---|
|
def random_password(length=40)
|
||
|
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
||
|
chars -= %w(0 O 1 l)
|
||
|
password = ''
|
||
|
password = +''
|
||
|
length.times {|i| password << chars[SecureRandom.random_number(chars.size)] }
|
||
|
self.password = password
|
||
|
self.password_confirmation = password
|
||
| config/initializers/10-patches.rb (working copy) | ||
|---|---|---|
|
module ActionMailer
|
||
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
||
|
def deliver(event)
|
||
|
recipients = [:to, :cc, :bcc].inject("") do |s, header|
|
||
|
recipients = [:to, :cc, :bcc].inject(+"") do |s, header|
|
||
|
r = Array.wrap(event.payload[header])
|
||
|
if r.any?
|
||
|
s << "\n #{header}: #{r.join(', ')}"
|
||
| lib/plugins/gravatar/lib/gravatar.rb (working copy) | ||
|---|---|---|
|
|
||
|
# Returns the base Gravatar URL for the given email hash
|
||
|
def gravatar_api_url(hash)
|
||
|
"//www.gravatar.com/avatar/#{hash}"
|
||
|
+"//www.gravatar.com/avatar/#{hash}"
|
||
|
end
|
||
|
# Return the gravatar URL for the given email address.
|
||
| lib/plugins/open_id_authentication/lib/open_id_authentication.rb (working copy) | ||
|---|---|---|
|
# dodge XRIs -- TODO: validate, don't just skip.
|
||
|
unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0))
|
||
|
# does it begin with http? if not, add it.
|
||
|
identifier = "http://#{identifier}" unless identifier =~ /^http/i
|
||
|
identifier = +"http://#{identifier}" unless identifier =~ /^http/i
|
||
|
# strip any fragments
|
||
|
identifier.gsub!(/\#(.*)$/, '')
|
||
| lib/redmine/codeset_util.rb (working copy) | ||
|---|---|---|
|
def self.replace_invalid_utf8(str)
|
||
|
return str if str.nil?
|
||
|
str = str.dup if str.frozen?
|
||
|
str.force_encoding('UTF-8')
|
||
|
if ! str.valid_encoding?
|
||
|
str = str.encode("UTF-16LE", :invalid => :replace,
|
||
| ... | ... | |
|
def self.to_utf8(str, encoding)
|
||
|
return str if str.nil?
|
||
|
str = str.dup if str.frozen?
|
||
|
str.force_encoding("ASCII-8BIT")
|
||
|
if str.empty?
|
||
|
str.force_encoding("UTF-8")
|
||
| ... | ... | |
|
def self.to_utf8_by_setting_internal(str)
|
||
|
return str if str.nil?
|
||
|
str = str.dup if str.frozen?
|
||
|
str.force_encoding('ASCII-8BIT')
|
||
|
return str if str.empty?
|
||
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||
| ... | ... | |
|
def self.from_utf8(str, encoding)
|
||
|
str ||= ''
|
||
|
str = str.dup if str.frozen?
|
||
|
str.force_encoding('UTF-8')
|
||
|
if encoding.upcase != 'UTF-8'
|
||
|
str = str.encode(encoding, :invalid => :replace,
|
||
| lib/redmine/export/csv.rb (working copy) | ||
|---|---|---|
|
col_sep = l(:general_csv_separator)
|
||
|
encoding = Encoding.find(options[:encoding]) rescue Encoding.find(l(:general_csv_encoding))
|
||
|
str = ''.force_encoding(encoding)
|
||
|
str = (+'').force_encoding(encoding)
|
||
|
if encoding == Encoding::UTF_8
|
||
|
# BOM
|
||
|
str = "\xEF\xBB\xBF".force_encoding(encoding)
|
||
|
str = (+"\xEF\xBB\xBF").force_encoding(encoding)
|
||
|
end
|
||
|
super(str, :col_sep => col_sep, :encoding => encoding, &block)
|
||
| lib/redmine/export/pdf.rb (working copy) | ||
|---|---|---|
|
</style>'
|
||
|
# Strip {{toc}} tags
|
||
|
txt.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i, '')
|
||
|
txt = txt.gsub(/<p>\{\{([<>]?)toc\}\}<\/p>/i, '')
|
||
|
writeHTMLCell(w, h, x, y, css_tag + txt, border, ln, fill)
|
||
|
end
|
||
| lib/redmine/export/pdf/issues_pdf_helper.rb (working copy) | ||
|---|---|---|
|
if query.grouped? &&
|
||
|
(group = query.group_by_column.group_value(issue)) != previous_group
|
||
|
pdf.SetFontStyle('B',10)
|
||
|
group_label = group.blank? ? 'None' : group.to_s.dup
|
||
|
group_label = group.blank? ? +'None' : group.to_s.dup
|
||
|
group_label << " (#{result_count_by_group[group]})"
|
||
|
pdf.bookmark group_label, 0, -1
|
||
|
pdf.RDMCell(table_width, row_height * 2, group_label, 'LR', 1, 'L')
|
||
| lib/redmine/field_format.rb (working copy) | ||
|---|---|---|
|
def parse_keyword(custom_field, keyword, &block)
|
||
|
separator = Regexp.escape ","
|
||
|
keyword = keyword.to_s
|
||
|
keyword = keyword.dup if keyword.frozen?
|
||
|
if custom_field.multiple?
|
||
|
values = []
|
||
| lib/redmine/helpers/diff.rb (working copy) | ||
|---|---|---|
|
add_at = nil
|
||
|
add_to = nil
|
||
|
del_at = nil
|
||
|
deleted = ""
|
||
|
deleted = +""
|
||
|
diff.each do |change|
|
||
|
pos = change[1]
|
||
|
if change[0] == "+"
|
||
| lib/redmine/helpers/gantt.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
@date_from = Date.civil(@year_from, @month_from, 1)
|
||
|
@date_to = (@date_from >> @months) - 1
|
||
|
@subjects = ''
|
||
|
@lines = ''
|
||
|
@subjects = +''
|
||
|
@lines = +''
|
||
|
@number_of_rows = nil
|
||
|
@truncated = false
|
||
|
if options.has_key?(:max_rows)
|
||
| ... | ... | |
|
:indent_increment => 20, :render => :subject,
|
||
|
:format => :html}.merge(options)
|
||
|
indent = options[:indent] || 4
|
||
|
@subjects = '' unless options[:only] == :lines
|
||
|
@lines = '' unless options[:only] == :subjects
|
||
|
@subjects = +'' unless options[:only] == :lines
|
||
|
@lines = +'' unless options[:only] == :subjects
|
||
|
@number_of_rows = 0
|
||
|
begin
|
||
|
Project.project_tree(projects) do |project, level|
|
||
| ... | ... | |
|
case object
|
||
|
when Issue
|
||
|
issue = object
|
||
|
css_classes = ''
|
||
|
css_classes = +''
|
||
|
css_classes << ' issue-overdue' if issue.overdue?
|
||
|
css_classes << ' issue-behind-schedule' if issue.behind_schedule?
|
||
|
css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
|
||
| ... | ... | |
|
css_classes << ' behind-start-date' if progress_date < self.date_from
|
||
|
css_classes << ' over-end-date' if progress_date > self.date_to
|
||
|
end
|
||
|
s = "".html_safe
|
||
|
s = (+"").html_safe
|
||
|
if issue.assigned_to.present?
|
||
|
assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
|
||
|
s << view.avatar(issue.assigned_to,
|
||
| ... | ... | |
|
view.content_tag(:span, s, :class => css_classes).html_safe
|
||
|
when Version
|
||
|
version = object
|
||
|
html_class = ""
|
||
|
html_class = +""
|
||
|
html_class << 'icon icon-package '
|
||
|
html_class << (version.behind_schedule? ? 'version-behind-schedule' : '') << " "
|
||
|
html_class << (version.overdue? ? 'version-overdue' : '')
|
||
| ... | ... | |
|
view.content_tag(:span, s, :class => html_class).html_safe
|
||
|
when Project
|
||
|
project = object
|
||
|
html_class = ""
|
||
|
html_class = +""
|
||
|
html_class << 'icon icon-projects '
|
||
|
html_class << (project.overdue? ? 'project-overdue' : '')
|
||
|
s = view.link_to_project(project).html_safe
|
||
| ... | ... | |
|
end
|
||
|
if has_children
|
||
|
content = view.content_tag(:span, nil, :class => :expander) + content
|
||
|
tag_options[:class] << ' open'
|
||
|
tag_options[:class] += ' open'
|
||
|
else
|
||
|
if params[:indent]
|
||
|
params = params.dup
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;"
|
||
|
style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width]
|
||
|
style += "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width]
|
||
|
tag_options[:style] = style
|
||
|
output = view.content_tag(:div, content, tag_options)
|
||
|
@subjects << output
|
||
| ... | ... | |
|
end
|
||
|
def html_task(params, coords, markers, label, object)
|
||
|
output = ''
|
||
|
output = +''
|
||
|
data_options = {}
|
||
|
data_options[:collapse_expand] = "#{object.class}-#{object.id}".downcase if object
|
||
| ... | ... | |
|
# Renders the task bar, with progress and late
|
||
|
if coords[:bar_start] && coords[:bar_end]
|
||
|
width = coords[:bar_end] - coords[:bar_start] - 2
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{coords[:bar_start]}px;"
|
||
|
style << "width:#{width}px;"
|
||
| ... | ... | |
|
output << view.content_tag(:div, ' '.html_safe, content_opt)
|
||
|
if coords[:bar_late_end]
|
||
|
width = coords[:bar_late_end] - coords[:bar_start] - 2
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{coords[:bar_start]}px;"
|
||
|
style << "width:#{width}px;"
|
||
| ... | ... | |
|
end
|
||
|
if coords[:bar_progress_end]
|
||
|
width = coords[:bar_progress_end] - coords[:bar_start] - 2
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{coords[:bar_start]}px;"
|
||
|
style << "width:#{width}px;"
|
||
| ... | ... | |
|
# Renders the markers
|
||
|
if markers
|
||
|
if coords[:start]
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{coords[:start]}px;"
|
||
|
style << "width:15px;"
|
||
| ... | ... | |
|
:data => data_options)
|
||
|
end
|
||
|
if coords[:end]
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{coords[:end] + params[:zoom]}px;"
|
||
|
style << "width:15px;"
|
||
| ... | ... | |
|
end
|
||
|
# Renders the label on the right
|
||
|
if label
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{(coords[:bar_end] || 0) + 8}px;"
|
||
|
style << "width:15px;"
|
||
| ... | ... | |
|
view.render_issue_tooltip(object).html_safe,
|
||
|
:class => "tip")
|
||
|
s += view.content_tag(:input, nil, :type => 'checkbox', :name => 'ids[]', :value => object.id, :style => 'display:none;', :class => 'toggle-selection')
|
||
|
style = ""
|
||
|
style = +""
|
||
|
style << "position: absolute;"
|
||
|
style << "top:#{params[:top]}px;"
|
||
|
style << "left:#{coords[:bar_start]}px;"
|
||
| lib/redmine/info.rb (working copy) | ||
|---|---|---|
|
def versioned_name; "#{app_name} #{Redmine::VERSION}" end
|
||
|
def environment
|
||
|
s = "Environment:\n"
|
||
|
s = +"Environment:\n"
|
||
|
s << [
|
||
|
["Redmine version", Redmine::VERSION],
|
||
|
["Ruby version", "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"],
|
||
| lib/redmine/pagination.rb (working copy) | ||
|---|---|---|
|
per_page_links = false if count.nil?
|
||
|
page_param = paginator.page_param
|
||
|
html = '<ul class="pages">'
|
||
|
html = +'<ul class="pages">'
|
||
|
if paginator.multiple_pages?
|
||
|
# \xc2\xab(utf-8) = «
|
||
| lib/redmine/scm/adapters/abstract_adapter.rb (working copy) | ||
|---|---|---|
|
def scm_iconv(to, from, str)
|
||
|
return nil if str.nil?
|
||
|
return str if to == from && str.encoding.to_s == from
|
||
|
str = str.dup if str.frozen?
|
||
|
str.force_encoding(from)
|
||
|
begin
|
||
|
str.encode(to)
|
||
| lib/redmine/scm/adapters/cvs_adapter.rb (working copy) | ||
|---|---|---|
|
def entries(path=nil, identifier=nil, options={})
|
||
|
logger.debug "<cvs> entries '#{path}' with identifier '#{identifier}'"
|
||
|
path_locale = scm_iconv(@path_encoding, 'UTF-8', path)
|
||
|
path_locale.force_encoding("ASCII-8BIT")
|
||
|
path_locale = path_locale.dup.force_encoding("ASCII-8BIT")
|
||
|
entries = Entries.new
|
||
|
cmd_args = %w|-q rls -e|
|
||
|
cmd_args << "-D" << time_to_cvstime_rlog(identifier) if identifier
|
||
| lib/redmine/scm/adapters/git_adapter.rb (working copy) | ||
|---|---|---|
|
cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
|
||
|
revisions = []
|
||
|
if identifier_from || identifier_to
|
||
|
revisions << ""
|
||
|
revisions << +""
|
||
|
revisions[0] << "#{identifier_from}.." if identifier_from
|
||
|
revisions[0] << "#{identifier_to}" if identifier_to
|
||
|
else
|
||
| ... | ... | |
|
end
|
||
|
elsif (parsing_descr == 0) && line.chomp.to_s == ""
|
||
|
parsing_descr = 1
|
||
|
changeset[:description] = ""
|
||
|
changeset[:description] = +""
|
||
|
elsif (parsing_descr == 1 || parsing_descr == 2) \
|
||
|
&& line =~ /^:\d+\s+\d+\s+[0-9a-f.]+\s+[0-9a-f.]+\s+(\w)\t(.+)$/
|
||
|
parsing_descr = 2
|
||
| lib/redmine/scm/adapters/subversion_adapter.rb (working copy) | ||
|---|---|---|
|
path ||= ''
|
||
|
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
||
|
entries = Entries.new
|
||
|
cmd = "#{self.class.sq_bin} list --xml #{target(path)}@#{identifier}"
|
||
|
cmd = +"#{self.class.sq_bin} list --xml #{target(path)}@#{identifier}"
|
||
|
cmd << credentials_string
|
||
|
shellout(cmd) do |io|
|
||
|
output = io.read.force_encoding('UTF-8')
|
||
| ... | ... | |
|
private
|
||
|
def credentials_string
|
||
|
str = ''
|
||
|
str = +''
|
||
|
str << " --username #{shell_quote(@login)}" unless @login.blank?
|
||
|
str << " --password #{shell_quote(@password)}" unless @login.blank? || @password.blank?
|
||
|
str << " --no-auth-cache --non-interactive"
|
||
| lib/redmine/unified_diff.rb (working copy) | ||
|---|---|---|
|
def line_to_html_raw(line, offsets)
|
||
|
if offsets
|
||
|
s = ''
|
||
|
s = +''
|
||
|
unless offsets.first == 0
|
||
|
s << CGI.escapeHTML(line[0..offsets.first-1])
|
||
|
end
|
||
| lib/redmine/wiki_formatting/markdown/formatter.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def extract_sections(index)
|
||
|
sections = ['', '', '']
|
||
|
sections = [+'', +'', +'']
|
||
|
offset = 0
|
||
|
i = 0
|
||
|
l = 1
|
||
| lib/redmine/wiki_formatting/textile/formatter.rb (working copy) | ||
|---|---|---|
|
@pre_list = []
|
||
|
text = self.dup
|
||
|
rip_offtags text, false, false
|
||
|
before = ''
|
||
|
s = ''
|
||
|
after = ''
|
||
|
before = +''
|
||
|
s = +''
|
||
|
after = +''
|
||
|
i = 0
|
||
|
l = 1
|
||
|
started = false
|
||
| lib/redmine/wiki_formatting/textile/redcloth3.rb (working copy) | ||
|---|---|---|
|
# Parses Textile attribute lists and builds an HTML attribute string
|
||
|
def pba( text_in, element = "" )
|
||
|
|
||
|
return '' unless text_in
|
||
|
return +'' unless text_in
|
||
|
style = []
|
||
|
text = text_in.dup
|
||
| ... | ... | |
|
id = id.starts_with?('wiki-id-') ? id : "wiki-id-#{id}" if id
|
||
|
atts = ''
|
||
|
atts = +''
|
||
|
atts << " style=\"#{ style.join }\"" unless style.empty?
|
||
|
atts << " class=\"#{ cls }\"" unless cls.to_s.empty?
|
||
|
atts << " lang=\"#{ lang }\"" if lang
|
||
| ... | ... | |
|
depth << tl
|
||
|
atts = pba( atts )
|
||
|
atts = shelve( atts ) if atts
|
||
|
lines[line_id] = "\t<#{ lT(tl) }l#{ atts }>\n\t<li>#{ content }"
|
||
|
lines[line_id] = +"\t<#{ lT(tl) }l#{ atts }>\n\t<li>#{ content }"
|
||
|
else
|
||
|
lines[line_id] = "\t\t<li>#{ content }"
|
||
|
lines[line_id] = +"\t\t<li>#{ content }"
|
||
|
end
|
||
|
last_line = line_id
|
||
| ... | ... | |
|
def block_textile_quotes( text )
|
||
|
text.gsub!( QUOTES_RE ) do |match|
|
||
|
lines = match.split( /\n/ )
|
||
|
quotes = ''
|
||
|
quotes = +''
|
||
|
indent = 0
|
||
|
lines.each do |line|
|
||
|
line =~ QUOTES_CONTENT_RE
|
||
| ... | ... | |
|
text.gsub!( CODE_RE ) do |m|
|
||
|
before,lang,code,after = $~[1..4]
|
||
|
lang = " lang=\"#{ lang }\"" if lang
|
||
|
rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }", false )
|
||
|
rip_offtags( +"#{ before }<code#{ lang }>#{ code }</code>#{ after }", false )
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
post = ")"+post # add closing parenth to post
|
||
|
end
|
||
|
atts = pba( atts )
|
||
|
atts = " href=\"#{ htmlesc url }#{ slash }\"#{ atts }"
|
||
|
atts = +" href=\"#{ htmlesc url }#{ slash }\"#{ atts }"
|
||
|
atts << " title=\"#{ htmlesc title }\"" if title
|
||
|
atts = shelve( atts ) if atts
|
||
|
|
||
| ... | ... | |
|
stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8]
|
||
|
htmlesc title
|
||
|
atts = pba( atts )
|
||
|
atts = " src=\"#{ htmlesc url.dup }\"#{ atts }"
|
||
|
atts = +" src=\"#{ htmlesc url.dup }\"#{ atts }"
|
||
|
atts << " title=\"#{ title }\"" if title
|
||
|
atts << " alt=\"#{ title }\""
|
||
|
# size = @getimagesize($url);
|
||
| ... | ... | |
|
next m unless uri_with_safe_scheme?(url)
|
||
|
out = ''
|
||
|
out = +''
|
||
|
out << "<a#{ shelve( " href=\"#{ href }\"" ) }>" if href
|
||
|
out << "<img#{ shelve( atts ) } />"
|
||
|
out << "</a>#{ href_a1 }#{ href_a2 }" if href
|
||
| ... | ... | |
|
if codepre - used_offtags.length > 0
|
||
|
htmlesc( line, :NoQuotes ) if escape_line
|
||
|
@pre_list.last << line
|
||
|
line = ""
|
||
|
line = +""
|
||
|
else
|
||
|
### htmlesc is disabled between CODE tags which will be parsed with highlighter
|
||
|
### Regexp in formatter.rb is : /<code\s+class="(\w+)">\s?(.+)/m
|
||
|
### NB: some changes were made not to use $N variables, because we use "match"
|
||
|
### and it breaks following lines
|
||
|
htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag && !first.match(/<code\s+class="(\w+)">/)
|
||
|
line = "<redpre##{ @pre_list.length }>"
|
||
|
line = +"<redpre##{ @pre_list.length }>"
|
||
|
first.match(/<#{ OFFTAGS }([^>]*)>/)
|
||
|
tag = $1
|
||
|
$2.to_s.match(/(class\=("[^"]+"|'[^']+'))/i)
|
||
|
tag << " #{$1}" if $1 && tag == 'code'
|
||
|
@pre_list << "<#{ tag }>#{ aftertag }"
|
||
|
@pre_list << +"<#{ tag }>#{ aftertag }"
|
||
|
end
|
||
|
elsif $1 and codepre > 0
|
||
|
if codepre - used_offtags.length > 0
|
||
|
htmlesc( line, :NoQuotes ) if escape_line
|
||
|
@pre_list.last << line
|
||
|
line = ""
|
||
|
line = +""
|
||
|
end
|
||
|
codepre -= 1 unless codepre.zero?
|
||
|
used_offtags = {} if codepre.zero?
|
||
| test/functional/attachments_controller_test.rb (working copy) | ||
|---|---|---|
|
assert a.save
|
||
|
assert_equal 'japanese-utf-8.txt', a.filename
|
||
|
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||
|
str_japanese = (+"\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e").force_encoding('UTF-8')
|
||
|
get :show, :params => {
|
||
|
:id => a.id
|
||
| test/functional/issues_controller_test.rb (working copy) | ||
|---|---|---|
|
def test_index_csv_big_5
|
||
|
with_settings :default_language => "zh-TW" do
|
||
|
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
|
||
|
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
|
||
|
str_utf8 = (+"\xe4\xb8\x80\xe6\x9c\x88").force_encoding('UTF-8')
|
||
|
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5')
|
||
|
issue = Issue.generate!(:subject => str_utf8)
|
||
|
get :index, :params => {
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
header = lines[0]
|
||
|
status = "\xaa\xac\xbaA".force_encoding('Big5')
|
||
|
status = (+"\xaa\xac\xbaA").force_encoding('Big5')
|
||
|
assert_include status, header
|
||
|
issue_line = lines.find {|l| l =~ /^#{issue.id},/}
|
||
|
assert_include str_big5, issue_line
|
||
| ... | ... | |
|
def test_index_csv_cannot_convert_should_be_replaced_big_5
|
||
|
with_settings :default_language => "zh-TW" do
|
||
|
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
|
||
|
str_utf8 = (+"\xe4\xbb\xa5\xe5\x86\x85").force_encoding('UTF-8')
|
||
|
issue = Issue.generate!(:subject => str_utf8)
|
||
|
get :index, :params => {
|
||
| ... | ... | |
|
lines = @response.body.chomp.split("\n")
|
||
|
header = lines[0]
|
||
|
issue_line = lines.find {|l| l =~ /^#{issue.id},/}
|
||
|
s1 = "\xaa\xac\xbaA".force_encoding('Big5') # status
|
||
|
s1 = (+"\xaa\xac\xbaA").force_encoding('Big5') # status
|
||
|
assert header.include?(s1)
|
||
|
s2 = issue_line.split(",")[2]
|
||
|
s3 = "\xa5H?".force_encoding('Big5') # subject
|
||
|
s3 = (+"\xa5H?").force_encoding('Big5') # subject
|
||
|
assert_equal s3, s2
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
def test_export_to_pdf_with_utf8_u_fffd
|
||
|
# U+FFFD
|
||
|
s = "\xef\xbf\xbd"
|
||
|
s.force_encoding('UTF-8') if s.respond_to?(:force_encoding)
|
||
|
s = +"\xef\xbf\xbd"
|
||
|
s.force_encoding('UTF-8')
|
||
|
issue = Issue.generate!(:subject => s)
|
||
|
["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
|
||
|
with_settings :default_language => lang do
|
||
| test/functional/repositories_filesystem_controller_test.rb (working copy) | ||
|---|---|---|
|
"when Encoding.default_external is not UTF-8. " +
|
||
|
"Current value is '#{Encoding.default_external.to_s}'"
|
||
|
else
|
||
|
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||
|
str_japanese = (+"\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e").force_encoding('UTF-8')
|
||
|
assert_select 'tr#L3 td.line-code', :text => /#{str_japanese}/
|
||
|
end
|
||
|
end
|
||
| test/functional/repositories_git_controller_test.rb (working copy) | ||
|---|---|---|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||
|
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||
|
PRJ_ID = 3
|
||
|
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8')
|
||
|
FELIX_HEX = "Felix Sch\xC3\xA4fer".force_encoding('UTF-8')
|
||
|
CHAR_1_HEX = (+"\xc3\x9c").force_encoding('UTF-8')
|
||
|
FELIX_HEX = (+"Felix Sch\xC3\xA4fer").force_encoding('UTF-8')
|
||
|
NUM_REV = 28
|
||
|
## Git, Mercurial and CVS path encodings are binary.
|
||
| test/functional/repositories_mercurial_controller_test.rb (working copy) | ||
|---|---|---|
|
assert @repository
|
||
|
@diff_c_support = true
|
||
|
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8')
|
||
|
@tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||
|
@branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8')
|
||
|
@branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
|
||
|
@tag_char_1 = (+"tag-#{CHAR_1_HEX}-00").force_encoding('UTF-8')
|
||
|
@branch_char_0 = (+"branch-#{CHAR_1_HEX}-00").force_encoding('UTF-8')
|
||
|
@branch_char_1 = (+"branch-#{CHAR_1_HEX}-01").force_encoding('UTF-8')
|
||
|
end
|
||
|
if ruby19_non_utf8_pass
|
||
| test/functional/timelog_report_test.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def test_csv_big_5
|
||
|
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
|
||
|
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
|
||
|
str_utf8 = (+"\xe4\xb8\x80\xe6\x9c\x88").force_encoding('UTF-8')
|
||
|
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5')
|
||
|
user = User.find_by_id(3)
|
||
|
user.firstname = str_utf8
|
||
|
user.lastname = "test-lastname"
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
# Headers
|
||
|
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||
|
s2 = "\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||
|
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||
|
s2 = (+"\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||
|
assert_equal s1, lines.first
|
||
|
# Total row
|
||
|
assert_equal "#{str_big5} #{user.lastname},7.30,7.30", lines[1]
|
||
|
assert_equal "#{s2},7.30,7.30", lines[2]
|
||
|
str_tw = "Chinese/Traditional (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)".force_encoding('UTF-8')
|
||
|
str_tw = (+"Chinese/Traditional (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)").force_encoding('UTF-8')
|
||
|
assert_equal str_tw, l(:general_lang_name)
|
||
|
assert_equal 'Big5', l(:general_csv_encoding)
|
||
|
assert_equal ',', l(:general_csv_separator)
|
||
| ... | ... | |
|
end
|
||
|
def test_csv_cannot_convert_should_be_replaced_big_5
|
||
|
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
|
||
|
str_utf8 = (+"\xe4\xbb\xa5\xe5\x86\x85").force_encoding('UTF-8')
|
||
|
user = User.find_by_id(3)
|
||
|
user.firstname = str_utf8
|
||
|
user.lastname = "test-lastname"
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
# Headers
|
||
|
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
|
||
|
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
|
||
|
assert_equal s1, lines.first
|
||
|
# Total row
|
||
|
s2 = "\xa5H?".force_encoding('Big5')
|
||
|
s2 = (+"\xa5H?").force_encoding('Big5')
|
||
|
assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1]
|
||
|
end
|
||
| ... | ... | |
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
|
lines = @response.body.chomp.split("\n")
|
||
|
# Headers
|
||
|
s1 = "Utilisateur;2011-11-11;Temps total".force_encoding('ISO-8859-1')
|
||
|
s2 = "Temps total".force_encoding('ISO-8859-1')
|
||
|
s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1')
|
||
|
s2 = (+"Temps total").force_encoding('ISO-8859-1')
|
||
|
assert_equal s1, lines.first
|
||
|
# Total row
|
||
|
assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1]
|
||
|
assert_equal "#{s2};7,30;7,30", lines[2]
|
||
|
str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8')
|
||
|
str_fr = (+"French (Fran\xc3\xa7ais)").force_encoding('UTF-8')
|
||
|
assert_equal str_fr, l(:general_lang_name)
|
||
|
assert_equal 'ISO-8859-1', l(:general_csv_encoding)
|
||
|
assert_equal ';', l(:general_csv_separator)
|
||
| test/helpers/application_helper_test.rb (working copy) | ||
|---|---|---|
|
def setup
|
||
|
super
|
||
|
set_tmp_attachments_directory
|
||
|
@russian_test = "\xd1\x82\xd0\xb5\xd1\x81\xd1\x82".force_encoding('UTF-8')
|
||
|
@russian_test = (+"\xd1\x82\xd0\xb5\xd1\x81\xd1\x82").force_encoding('UTF-8')
|
||
|
end
|
||
|
test "#link_to_if_authorized for authorized user should allow using the :controller and :action for the target link" do
|
||
| ... | ... | |
|
end
|
||
|
def test_parse_redmine_links_should_handle_a_tag_without_attributes
|
||
|
text = '<a>http://example.com</a>'
|
||
|
text = +'<a>http://example.com</a>'
|
||
|
expected = text.dup
|
||
|
parse_redmine_links(text, nil, nil, nil, true, {})
|
||
|
assert_equal expected, text
|
||
| ... | ... | |
|
end
|
||
|
def test_truncate_single_line_non_ascii
|
||
|
ja = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
|
||
|
ja = (+"\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e").force_encoding('UTF-8')
|
||
|
result = truncate_single_line_raw("#{ja}\n#{ja}\n#{ja}", 10)
|
||
|
assert_equal "#{ja} #{ja}...", result
|
||
|
assert !result.html_safe?
|
||
| test/integration/api_test/authentication_test.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def test_invalid_utf8_credentials_should_not_trigger_an_error
|
||
|
invalid_utf8 = "\x82".force_encoding('UTF-8')
|
||
|
invalid_utf8 = (+"\x82").force_encoding('UTF-8')
|
||
|
assert !invalid_utf8.valid_encoding?
|
||
|
assert_nothing_raised do
|
||
|
get '/users/current.xml', :headers => credentials(invalid_utf8, "foo")
|
||
| test/object_helpers.rb (working copy) | ||
|---|---|---|
|
module ObjectHelpers
|
||
|
def User.generate!(attributes={})
|
||
|
@generated_user_login ||= 'user0'
|
||
|
@generated_user_login ||= +'user0'
|
||
|
@generated_user_login.succ!
|
||
|
user = User.new(attributes)
|
||
|
user.login = @generated_user_login.dup if user.login.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Group.generate!(attributes={})
|
||
|
@generated_group_name ||= 'Group 0'
|
||
|
@generated_group_name ||= +'Group 0'
|
||
|
@generated_group_name.succ!
|
||
|
group = Group.new(attributes)
|
||
|
group.name = @generated_group_name.dup if group.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Project.generate!(attributes={})
|
||
|
@generated_project_identifier ||= 'project-0000'
|
||
|
@generated_project_identifier ||= +'project-0000'
|
||
|
@generated_project_identifier.succ!
|
||
|
project = Project.new(attributes)
|
||
|
project.name = @generated_project_identifier.dup if project.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def IssueStatus.generate!(attributes={})
|
||
|
@generated_status_name ||= 'Status 0'
|
||
|
@generated_status_name ||= +'Status 0'
|
||
|
@generated_status_name.succ!
|
||
|
status = IssueStatus.new(attributes)
|
||
|
status.name = @generated_status_name.dup if status.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Tracker.generate(attributes={})
|
||
|
@generated_tracker_name ||= 'Tracker 0'
|
||
|
@generated_tracker_name ||= +'Tracker 0'
|
||
|
@generated_tracker_name.succ!
|
||
|
tracker = Tracker.new(attributes)
|
||
|
tracker.name = @generated_tracker_name.dup if tracker.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Role.generate!(attributes={})
|
||
|
@generated_role_name ||= 'Role 0'
|
||
|
@generated_role_name ||= +'Role 0'
|
||
|
@generated_role_name.succ!
|
||
|
role = Role.new(attributes)
|
||
|
role.name = @generated_role_name.dup if role.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Version.generate!(attributes={})
|
||
|
@generated_version_name ||= 'Version 0'
|
||
|
@generated_version_name ||= +'Version 0'
|
||
|
@generated_version_name.succ!
|
||
|
version = Version.new(attributes)
|
||
|
version.name = @generated_version_name.dup if version.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def AuthSource.generate!(attributes={})
|
||
|
@generated_auth_source_name ||= 'Auth 0'
|
||
|
@generated_auth_source_name ||= +'Auth 0'
|
||
|
@generated_auth_source_name.succ!
|
||
|
source = AuthSource.new(attributes)
|
||
|
source.name = @generated_auth_source_name.dup if source.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Board.generate!(attributes={})
|
||
|
@generated_board_name ||= 'Forum 0'
|
||
|
@generated_board_name ||= +'Forum 0'
|
||
|
@generated_board_name.succ!
|
||
|
board = Board.new(attributes)
|
||
|
board.name = @generated_board_name.dup if board.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Attachment.generate!(attributes={})
|
||
|
@generated_filename ||= 'testfile0'
|
||
|
@generated_filename ||= +'testfile0'
|
||
|
@generated_filename.succ!
|
||
|
attributes = attributes.dup
|
||
|
attachment = Attachment.new(attributes)
|
||
| ... | ... | |
|
end
|
||
|
def CustomField.generate!(attributes={})
|
||
|
@generated_custom_field_name ||= 'Custom field 0'
|
||
|
@generated_custom_field_name ||= +'Custom field 0'
|
||
|
@generated_custom_field_name.succ!
|
||
|
field = new(attributes)
|
||
|
field.name = @generated_custom_field_name.dup if field.name.blank?
|
||
| ... | ... | |
|
end
|
||
|
def Changeset.generate!(attributes={})
|
||
|
@generated_changeset_rev ||= '123456'
|
||
|
@generated_changeset_rev ||= +'123456'
|
||
|
@generated_changeset_rev.succ!
|
||
|
changeset = new(attributes)
|
||
|
changeset.repository ||= Project.find(1).repository
|
||
| test/unit/attachment_test.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
def test_latest_attach_should_not_error_with_string_with_invalid_encoding
|
||
|
string = "width:50\xFE-Image.jpg".force_encoding('UTF-8')
|
||
|
string = (+"width:50\xFE-Image.jpg").force_encoding('UTF-8')
|
||
|
assert_equal false, string.valid_encoding?
|
||
|
Attachment.latest_attach(Attachment.limit(2).to_a, string)
|
||
| test/unit/changeset_test.rb (working copy) | ||
|---|---|---|
|
def test_comments_should_be_converted_to_utf8
|
||
|
proj = Project.find(3)
|
||
|
# str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
|
||
|
str = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT")
|
||
|
str = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT")
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
:scmid => '12345',
|
||
|
:comments => str)
|
||
|
assert( c.save )
|
||
|
str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1.".force_encoding("UTF-8")
|
||
|
str_utf8 = (+"Texte encod\xc3\xa9 en ISO-8859-1.").force_encoding("UTF-8")
|
||
|
assert_equal str_utf8, c.comments
|
||
|
end
|
||
|
def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1
|
||
|
proj = Project.find(3)
|
||
|
# str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
|
||
|
str1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("UTF-8")
|
||
|
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
|
||
|
str1 = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("UTF-8")
|
||
|
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis
|
||
|
proj = Project.find(3)
|
||
|
str = "test\xb5\xfetest\xb5\xfe".force_encoding('ASCII-8BIT')
|
||
|
str = (+"test\xb5\xfetest\xb5\xfe").force_encoding('ASCII-8BIT')
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| ... | ... | |
|
end
|
||
|
def test_comments_should_be_converted_all_latin1_to_utf8
|
||
|
s1 = "\xC2\x80"
|
||
|
s2 = "\xc3\x82\xc2\x80"
|
||
|
s1 = +"\xC2\x80"
|
||
|
s2 = +"\xc3\x82\xc2\x80"
|
||
|
s4 = s2.dup
|
||
|
s3 = s1.dup
|
||
|
s1.force_encoding('ASCII-8BIT')
|
||
| ... | ... | |
|
def test_invalid_utf8_sequences_in_paths_should_be_replaced
|
||
|
proj = Project.find(3)
|
||
|
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8")
|
||
|
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT")
|
||
|
str1 = (+"Texte encod\xe9 en ISO-8859-1").force_encoding("UTF-8")
|
||
|
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
|
||
|
r = Repository::Bazaar.create!(
|
||
|
:project => proj,
|
||
|
:url => '/tmp/test/bazaar',
|
||
| test/unit/custom_field_test.rb (working copy) | ||
|---|---|---|
|
def test_possible_values_should_return_utf8_encoded_strings
|
||
|
field = CustomField.new
|
||
|
s = "Value".force_encoding('BINARY')
|
||
|
s = "Value".b
|
||
|
field.possible_values = s
|
||
|
assert_equal [s], field.possible_values
|
||
|
assert_equal 'UTF-8', field.possible_values.first.encoding.name
|
||
| test/unit/group_test.rb (working copy) | ||
|---|---|---|
|
def test_blank_name_error_message_fr
|
||
|
set_language_if_valid 'fr'
|
||
|
str = "Nom doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
|
||
|
str = (+"Nom doit \xc3\xaatre renseign\xc3\xa9(e)").force_encoding('UTF-8')
|
||
|
g = Group.new
|
||
|
assert !g.save
|
||
|
assert_include str, g.errors.full_messages
|
||
| test/unit/lib/redmine/codeset_util_test.rb (working copy) | ||
|---|---|---|
|
def test_to_utf8_by_setting_from_latin1
|
||
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
||
|
s1 = "Texte encod\xc3\xa9".force_encoding("UTF-8")
|
||
|
s2 = "Texte encod\xe9".force_encoding("ASCII-8BIT")
|
||
|
s1 = (+"Texte encod\xc3\xa9").force_encoding("UTF-8")
|
||
|
s2 = (+"Texte encod\xe9").force_encoding("ASCII-8BIT")
|
||
|
s3 = s2.dup.force_encoding("UTF-8")
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
|
||
| ... | ... | |
|
def test_to_utf8_by_setting_from_euc_jp
|
||
|
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
|
||
|
s1 = "\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3".force_encoding("UTF-8")
|
||
|
s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3".force_encoding("ASCII-8BIT")
|
||
|
s1 = (+"\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3").force_encoding("UTF-8")
|
||
|
s2 = (+"\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3").force_encoding("ASCII-8BIT")
|
||
|
s3 = s2.dup.force_encoding("UTF-8")
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
|
||
| ... | ... | |
|
def test_to_utf8_by_setting_should_be_converted_all_latin1
|
||
|
with_settings :repositories_encodings => 'ISO-8859-1' do
|
||
|
s1 = "\xc3\x82\xc2\x80".force_encoding("UTF-8")
|
||
|
s2 = "\xC2\x80".force_encoding("ASCII-8BIT")
|
||
|
s1 = (+"\xc3\x82\xc2\x80").force_encoding("UTF-8")
|
||
|
s2 = (+"\xC2\x80").force_encoding("ASCII-8BIT")
|
||
|
s3 = s2.dup.force_encoding("UTF-8")
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
|
||
|
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
|
||
| ... | ... | |
|
end
|
||
|
def test_to_utf8_by_setting_returns_ascii_as_utf8
|
||
|
s1 = "ASCII".force_encoding("UTF-8")
|
||
|
s1 = (+"ASCII").force_encoding("UTF-8")
|
||
|
s2 = s1.dup.force_encoding("ISO-8859-1")
|
||
- « Previous
- 1
- 2
- Next »