[Apt-listbugs-commits] [apt-listbugs] 01/03: encode strings for HTML bug lists

Francesco Poli frx-guest at moszumanska.debian.org
Sun Mar 22 15:36:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

frx-guest pushed a commit to branch master
in repository apt-listbugs.

commit 822a260f92b511ac958a1f6c1bf539b50c2d06cc
Author: Francesco Poli (wintermute) <invernomuto at paranoici.org>
Date:   Sun Mar 15 17:29:36 2015 +0100

    encode strings for HTML bug lists
---
 debian/changelog         |  1 +
 lib/aptlistbugs/logic.rb | 36 ++++++++++++++++++------------------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fc611ca..5897efb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ apt-listbugs (0.1.17) UNRELEASED; urgency=medium
     debian/copyright files, and in man page, as well
   * fixed the man page: updated the example output consistently with
     the presence of the "b<id>" identifiers
+  * improved HTML bug lists (strings are now encoded to be valid XML)
 
  -- Francesco Poli (wintermute) <invernomuto at paranoici.org>  Sun, 04 Jan 2015 11:42:30 +0100
 
diff --git a/lib/aptlistbugs/logic.rb b/lib/aptlistbugs/logic.rb
index 30020fe..b471eda 100644
--- a/lib/aptlistbugs/logic.rb
+++ b/lib/aptlistbugs/logic.rb
@@ -722,18 +722,18 @@ class Viewer
       stats.each { |stat|
         sub = bugs.sub("stat", stat)
         if sub.size > 0
-          o.print "\n    <table class=\"bug_table\" summary=\""
+          o.print "\n    <table class=\"bug_table\" summary="
           # TRANSLATORS: this is a summary description of the structure of a table (for accessibility)
-          o.print _("The top row describes the meaning of the columns; the other rows describe bug reports, one per row")
-          o.print "\">\n"
-          o.puts "      <caption>\n        " + @config.statmap(stat)
+          o.print _("The top row describes the meaning of the columns; the other rows describe bug reports, one per row").encode(:xml => :attr)
+          o.print ">\n"
+          o.puts "      <caption>\n        " + @config.statmap(stat).encode(:xml => :text)
           o.puts "      </caption>"
           o.puts "\n      <tr class=\"header\">"
-          o.puts "        <th class=\"pkg\">" + _("package") + "</th>"
-          o.puts "\n        <th>" + _("version change") + "</th>"
-          o.puts "\n        <th>" + _("severity") + "</th>"
-          o.puts "\n        <th>" + _("bug number") + "</th>"
-          o.puts "\n        <th class=\"desc\">" + _("description") + "</th>"
+          o.puts "        <th class=\"pkg\">" + _("package").encode(:xml => :text) + "</th>"
+          o.puts "\n        <th>" + _("version change").encode(:xml => :text) + "</th>"
+          o.puts "\n        <th>" + _("severity").encode(:xml => :text) + "</th>"
+          o.puts "\n        <th>" + _("bug number").encode(:xml => :text) + "</th>"
+          o.puts "\n        <th class=\"desc\">" + _("description").encode(:xml => :text) + "</th>"
           o.puts "      </tr>"
           yield sub
           o.puts "    </table>\n    <hr class=\"nocss\" />"
@@ -751,25 +751,25 @@ class Viewer
       tmp.puts "<head>"
       tmp.puts "  <meta http-equiv=\"Content-type\" content=\"text/html; charset=#{Locale.charset}\" />"
       tmp.puts "  <meta name=\"generator\" content=\"apt-listbugs\" />"
-      tmp.puts "\n  <title>" + _("Relevant bugs for your upgrade") + "</title>"
+      tmp.puts "\n  <title>" + _("Relevant bugs for your upgrade").encode(:xml => :text) + "</title>"
       tmp.puts "  <link href=\"/etc/apt/listbugs/bug-list.css\" rel=\"stylesheet\" type=\"text/css\" />"
       tmp.puts "</head>\n\n<body>\n  <div id=\"page_title\">"
-      tmp.puts "    <h1 class=\"title\">" + _("Relevant bugs for your upgrade") + "</h1>"
-      tmp.puts "\n    <h5 class=\"generated\">" + _("by apt-listbugs") + "</h5>"
+      tmp.puts "    <h1 class=\"title\">" + _("Relevant bugs for your upgrade").encode(:xml => :text) + "</h1>"
+      tmp.puts "\n    <h5 class=\"generated\">" + _("by apt-listbugs").encode(:xml => :text) + "</h5>"
       tmp.puts "  </div>\n\n  <div id=\"page_body\">"
       tmp.puts "    <hr class=\"nocss\" />"
 
       each_state_table(tmp, bugs, @config.stats) { |bugs|
         bugs.each { |bug|
           pkg_key = bug.pkg_key
-          tmp.puts "\n      <tr class=\"#{bug.severity}\">"
-          tmp.puts "        <td class=\"pkg\">#{pkg_key}</td>"
+          tmp.puts "\n      <tr class=#{bug.severity.encode(:xml => :attr)}>"
+          tmp.puts "        <td class=\"pkg\">#{pkg_key.encode(:xml => :text)}</td>"
           tmp.print "\n        <td>"
-          tmp.print "#{cur_pkgs[pkg_key]['version']} " if cur_pkgs[pkg_key] != nil
-          tmp.print "#{@config.xarrow} #{new_pkgs[pkg_key]['version']}" if new_pkgs[pkg_key] != nil
-          tmp.puts "</td>\n\n        <td>#{bug.severity}</td>"
+          tmp.print "#{cur_pkgs[pkg_key]['version'].encode(:xml => :text)} " if cur_pkgs[pkg_key] != nil
+          tmp.print "#{@config.arrow.encode(:xml => :text)} #{new_pkgs[pkg_key]['version'].encode(:xml => :text)}" if new_pkgs[pkg_key] != nil
+          tmp.puts "</td>\n\n        <td>#{bug.severity.encode(:xml => :text)}</td>"
           tmp.puts "\n        <td><a href=\"http://bugs.debian.org/#{bug.bug_number}\">##{bug.bug_number}</a></td>"
-          tmp.puts "\n        <td class=\"desc\">#{bug.desc}</td>\n      </tr>"
+          tmp.puts "\n        <td class=\"desc\">#{bug.desc.encode(:xml => :text)}</td>\n      </tr>"
         }
       }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/apt-listbugs/apt-listbugs.git



More information about the Apt-listbugs-commits mailing list