New method Api::Utils.split_newlines(input) in order to split a string by newlines, whatever the encoding of return carriage.
#
module ResourceHelper
- def violation_html_message(violation)
- violation.message ? h(violation.message).split(/\r?\n|\r/).join('<br/>') : ''
- end
end
\ No newline at end of file
markdown ? Java::OrgSonarServerUi::JRubyFacade.markdownToHtml(ERB::Util.html_escape(markdown)) : ''
end
+ # splits a string into an array of lines
+ def self.split_newlines(input)
+ # Don't limit number of returned fields and don't suppress trailing empty fields by setting second parameter to negative value.
+ # See http://jira.codehaus.org/browse/SONAR-2282
+ input.split(/\r?\n|\r/, -1)
+ end
end
if message.blank?
rule.name
else
- parts=message.split(/\r?\n|\r/, -1)
+ parts=Api::Utils.split_newlines(message)
parts.size==0 ? rule.name : parts[0]
end
end
end
+
+ def html_message
+ @html_message ||=
+ begin
+ message ? Api::Utils.split_newlines(ERB::Util.html_escape(message)).join('<br/>') : ''
+ end
+ end
def to_json(include_review=false)
json = {}
end
def lines(encode)
- SnapshotSource.split_newlines(encoded_data(encode))
+ Api::Utils.split_newlines(encoded_data(encode))
end
def syntax_highlighted_source
end
def syntax_highlighted_lines
- SnapshotSource.split_newlines(syntax_highlighted_source)
+ Api::Utils.split_newlines(syntax_highlighted_source)
end
- private
- def self.split_newlines(input)
- # Don't limit number of returned fields and don't suppress trailing empty fields by setting second parameter to negative value.
- # See http://jira.codehaus.org/browse/SONAR-2282
- input.split(/\r?\n|\r/, -1)
- end
end
</div>
<div class="discussionComment first">
- <%= h(violation.message) -%>
+ <%= violation.html_message -%>
</div>
<%