module SCSSLint
  # Reports lints in an XML format.
  class Reporter::XMLReporter < Reporter
    def report_lints
      output = '<?xml version="1.0" encoding="utf-8"?>'

      output << '<lint>'
      lints.group_by(&:filename).each do |filename, file_lints|
        output << "<file name='#{filename}'>"

        file_lints.each do |lint|
          output << "<issue line='#{lint.line}' " <<
                           "severity='#{lint.severity}' " <<
                           "reason='#{lint.description}' />"
        end

        output << '</file>'
      end
      output << '</lint>'

      output
    end
  end
end

module SCSSLint
  # Reports lints in an XML format.
  class Reporter::XMLReporter < Reporter
    def report_lints
      output = '<?xml version="1.0" encoding="utf-8"?>'

      output << '<lint>'
      lints.group_by(&:filename).each do |filename, file_lints|
        output << "<file name=#{filename.encode(:xml => :attr)}>"


        file_lints.each do |lint|
          output << "<issue line=\"#{lint.line}\" " <<
                           "severity=\"#{lint.severity}\" " <<
                           "reason=#{lint.description.encode(:xml => :attr)} />"
        end

        output << '</file>'
      end
      output << '</lint>'

      output
    end
  end
end

Update XmlReporter to XML encode attribute strings
Update XmlReporter to XML encode attribute strings

Avoids problem where filename or description contains illegal XML
characters (like an ampersand) by escaping the output.

Change-Id: I161de23cd8d52d5b8bab540457fd5fcb4d44add9
Reviewed-on: http://gerrit.causes.com/37215
Tested-by: jenkins <d95b56ce41a2e1ac4cecdd398defd7414407cc08@causes.com>
Reviewed-by: Shane da Silva <6f6e68d1df92f30cb4b3ce35260ddf94a402f33d@causes.com>
